/* ============================================
   ICSD Games — Base Styles (shared across all games)
   ============================================ */

:root {
    --game-color: var(--icsd-primary, #2CA180);
    --game-color-light: var(--icsd-primary-light, #5DCAA5);
}

/* === Layout === */
.icsd-game-page {
    padding: 0 0 80px;
    position: relative;
    z-index: 2;
}

.icsd-game-breadcrumb {
    padding: 24px 0 16px;
    color: var(--icsd-text-muted);
    font-size: 13px;
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.icsd-game-breadcrumb a {
    color: var(--icsd-text-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.icsd-game-breadcrumb a:hover {
    color: var(--game-color);
}
.icsd-game-breadcrumb .sep {
    color: var(--icsd-border);
}
.icsd-game-breadcrumb .current {
    color: var(--icsd-text);
    font-weight: 500;
}

/* === Game Hero === */
.icsd-game-hero {
    background: var(--icsd-surface);
    border: 1px solid var(--icsd-border);
    border-radius: 16px;
    padding: 28px 32px;
    margin-bottom: 24px;
}
.icsd-game-hero-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.icsd-game-hero-meta .tag {
    background: var(--icsd-bg-alt);
    color: var(--game-color);
    border: 1px solid var(--icsd-border);
    padding: 4px 12px;
    border-radius: 100px;
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
    font-size: 11px;
}
.icsd-game-hero h1 {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 800;
    color: var(--icsd-text);
    display: flex;
    align-items: center;
    gap: 12px;
}
.icsd-game-hero h1 .icon {
    font-size: 36px;
    line-height: 1;
}
.icsd-game-hero p {
    margin: 0;
    color: var(--icsd-text-muted);
    font-size: 14px;
    line-height: 1.8;
}

/* === Game Layout: Game + Sidebar === */
.icsd-game-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

.icsd-game-board-wrap {
    background: var(--icsd-surface);
    border: 1px solid var(--icsd-border);
    border-radius: 16px;
    padding: 24px;
    min-width: 0;
}

/* === Score & Controls Bar === */
.icsd-game-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.icsd-game-stats .scores {
    display: flex;
    gap: 8px;
}
.icsd-game-score-box {
    background: var(--icsd-bg-alt);
    border: 1px solid var(--icsd-border);
    border-radius: 10px;
    padding: 8px 14px;
    min-width: 80px;
    text-align: center;
}
.icsd-game-score-box .label {
    display: block;
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
    font-size: 10px;
    color: var(--icsd-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.icsd-game-score-box .value {
    display: block;
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--game-color);
}

/* === Buttons === */
.icsd-game-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--icsd-border);
    background: var(--icsd-bg-alt);
    color: var(--icsd-text);
    border-radius: 10px;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.icsd-game-btn:hover {
    background: var(--icsd-surface-2);
    border-color: var(--game-color);
    color: var(--game-color);
}
.icsd-game-btn.primary {
    background: var(--game-color);
    color: #fff;
    border-color: var(--game-color);
}
.icsd-game-btn.primary:hover {
    background: var(--game-color-light);
    color: #fff;
}

/* === Sidebar (Leaderboard + Personal Best) === */
.icsd-game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.icsd-game-card {
    background: var(--icsd-surface);
    border: 1px solid var(--icsd-border);
    border-radius: 12px;
    padding: 18px 20px;
}
.icsd-game-card h3 {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--game-color);
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--icsd-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Personal Best */
.icsd-personal-best {
    text-align: center;
}
.icsd-personal-best .pb-value {
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
    font-size: 36px;
    font-weight: 800;
    color: var(--game-color);
    line-height: 1;
    margin: 8px 0;
}
.icsd-personal-best .pb-label {
    color: var(--icsd-text-muted);
    font-size: 12px;
}
.icsd-personal-best .pb-rank {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--icsd-border);
    font-size: 12px;
    color: var(--icsd-text-muted);
}
.icsd-personal-best .pb-rank strong {
    color: var(--game-color);
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
    font-size: 16px;
}

/* Leaderboard List */
.icsd-leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: lb-counter;
}
.icsd-leaderboard-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background 0.2s;
    margin-bottom: 2px;
    font-size: 13px;
}
.icsd-leaderboard-list li:hover {
    background: var(--icsd-bg-alt);
}
.icsd-leaderboard-list .rank {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
    font-size: 12px;
    font-weight: 700;
    background: var(--icsd-bg-alt);
    color: var(--icsd-text-muted);
}
.icsd-leaderboard-list li:nth-child(1) .rank {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #fff;
}
.icsd-leaderboard-list li:nth-child(2) .rank {
    background: linear-gradient(135deg, #C0C0C0, #808080);
    color: #fff;
}
.icsd-leaderboard-list li:nth-child(3) .rank {
    background: linear-gradient(135deg, #CD7F32, #8B4513);
    color: #fff;
}
.icsd-leaderboard-list .player {
    flex: 1;
    color: var(--icsd-text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.icsd-leaderboard-list .score {
    color: var(--game-color);
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
    font-weight: 700;
    font-size: 13px;
}
.icsd-leaderboard-empty {
    text-align: center;
    color: var(--icsd-text-muted);
    font-size: 13px;
    padding: 20px 0;
}

/* === Game Over Modal === */
.icsd-game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    z-index: 10;
}
.icsd-game-overlay.is-active {
    display: flex;
}
.icsd-game-overlay-content {
    background: var(--icsd-surface);
    border: 1px solid var(--game-color);
    border-radius: 16px;
    padding: 30px 36px;
    text-align: center;
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.icsd-game-overlay-content h2 {
    margin: 0 0 6px;
    font-size: 22px;
    color: var(--icsd-text);
}
.icsd-game-overlay-content .final-score {
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
    font-size: 44px;
    font-weight: 800;
    color: var(--game-color);
    margin: 14px 0;
    line-height: 1;
}
.icsd-game-overlay-content .rank-info {
    color: var(--icsd-text-muted);
    font-size: 13px;
    margin-bottom: 16px;
}
.icsd-game-overlay-content .rank-info strong {
    color: var(--game-color);
    font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
}
.icsd-game-overlay-content input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--icsd-border);
    border-radius: 8px;
    background: var(--icsd-bg-alt);
    color: var(--icsd-text);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 14px;
    margin-bottom: 12px;
    text-align: center;
    direction: rtl;
}
.icsd-game-overlay-content input[type="text"]:focus {
    outline: none;
    border-color: var(--game-color);
}
.icsd-game-overlay-content .actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Skip submit button */
.icsd-skip-submit {
    background: transparent;
    border: none;
    color: var(--icsd-text-muted);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 12px;
    cursor: pointer;
    margin-top: 12px;
    text-decoration: underline;
}
.icsd-skip-submit:hover {
    color: var(--icsd-text);
}

/* === How to Play Box === */
.icsd-how-to-play {
    background: var(--icsd-bg-alt);
    border: 1px solid var(--icsd-border);
    border-radius: 12px;
    padding: 14px 18px;
    margin-top: 18px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--icsd-text-muted);
}
.icsd-how-to-play strong {
    color: var(--icsd-text);
}
.icsd-how-to-play kbd {
    display: inline-block;
    background: var(--icsd-surface);
    border: 1px solid var(--icsd-border);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--icsd-text);
    margin: 0 2px;
}

/* === Responsive === */
@media (max-width: 991px) {
    .icsd-game-layout {
        grid-template-columns: 1fr;
    }
    .icsd-game-sidebar {
        order: 2;
    }
    .icsd-game-board-wrap {
        order: 1;
    }
}
@media (max-width: 575px) {
    .icsd-game-hero {
        padding: 20px 18px;
    }
    .icsd-game-hero h1 {
        font-size: 22px;
    }
    .icsd-game-board-wrap {
        padding: 16px;
    }
    .icsd-game-stats {
        flex-direction: column;
        align-items: stretch;
    }
    .icsd-game-stats .scores {
        justify-content: center;
    }
}
