/* Solitaire - Modern CSS Grid & Ergonomik Mobil CSS Sistemi */

:root {
    /* Renk Paleti ve Varsayılan Tema: Emerald Cyber-Felt */
    --bg-main: radial-gradient(ellipse at 50% 35%, #1b6a3b 0%, #0c3b1e 70%, #051d0f 100%);
    --bg-card-slot: rgba(0, 0, 0, 0.18);
    --border-card-slot: rgba(255, 255, 255, 0.28);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #38bdf8;
    --accent-gold: #f59e0b;
    --header-bg: rgba(15, 23, 42, 0.92);
    
    /* Kart Ölçüleri ve Dinamik Ölçekleme */
    --card-width: clamp(48px, 13vw, 92px);
    --card-height: calc(var(--card-width) * 1.4);
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Tema Varyasyonları */
body.theme-retro-green {
    --bg-main: radial-gradient(ellipse at 50% 35%, #229c4d 0%, #15803d 70%, #0f5829 100%);
    --header-bg: rgba(20, 83, 45, 0.92);
}

body.theme-midnight-velvet {
    --bg-main: radial-gradient(ellipse at 50% 35%, #1e293b 0%, #0f172a 70%, #020617 100%);
    --header-bg: rgba(30, 41, 59, 0.92);
}

body.theme-cyber-neon {
    --bg-main: radial-gradient(ellipse at 50% 35%, #0f172a 0%, #020617 70%, #000000 100%);
    --header-bg: rgba(15, 23, 42, 0.95);
    --border-card-slot: rgba(56, 189, 248, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none !important;
}

body {
    font-family: var(--font-main);
    background: var(--bg-main);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    transition: background 0.3s ease;
}

/* Ana Konteyner: CSS Grid Layout (Orantılı Mobil & Masaüstü Kullanımı) */
.solitaire-container {
    display: grid;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
        "ad-banner"
        "app-header"
        "game-board";
    height: 100vh;
    height: 100dvh;
    width: 100vw;
}

/* 1. Reklam Slotu (En Üstte - Pasif) */
.ad-banner-slot {
    grid-area: ad-banner;
    background: #000;
    color: #94a3b8;
    text-align: center;
    font-size: 11px;
    padding: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* 2. Header ve Menü Paneli (Üst-Orta) */
.app-header {
    grid-area: app-header;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 100;
    touch-action: auto !important;
}

.header-top-row, .header-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
}
.logo .icon {
    font-size: 22px;
    color: var(--accent-blue);
}
.logo h1 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.stats-group {
    display: flex;
    gap: 14px;
    font-size: 13px;
    color: var(--text-secondary);
}
.stat-item strong {
    color: var(--text-primary);
    font-weight: 700;
}

.seed-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.seed-badge {
    background: rgba(255, 255, 255, 0.12);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.virgin-badge {
    background: linear-gradient(135deg, #d97706, #f59e0b);
    color: #fff;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 800;
}

.action-controls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn {
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: transform 0.1s ease, background-color 0.2s ease;
    touch-action: manipulation !important;
}
.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}
.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* 3. Ana Oyun Alanı (Ekran Yüksekliğini Dolduran Orantılı Yerleşim) */
.game-board {
    grid-area: game-board;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    height: 100%;
    overflow-y: auto;
    touch-action: none !important;
}

.top-piles-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.stock-waste-group, .foundation-group {
    display: flex;
    gap: 10px;
}

.tableau-group {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    flex: 1;
    min-height: calc(var(--card-height) * 3);
}

/* Kart Yuvaları (Piles) */
.pile {
    width: var(--card-width);
    height: var(--card-height);
    background: var(--bg-card-slot);
    border: 1.5px dashed var(--border-card-slot);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.35);
    touch-action: none !important;
}

.pile-placeholder {
    font-size: 22px;
    color: rgba(255, 255, 255, 0.35);
    font-weight: bold;
}

.foundation-pile {
    border: 1.5px stroke rgba(255, 255, 255, 0.35);
    border-style: solid;
}

.foundation-ace-marker {
    font-size: 26px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.32);
    font-family: var(--font-main);
    letter-spacing: -0.5px;
}

.tableau-pile {
    position: relative;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.15);
}

/* Kart DOM Yapısı */
.card {
    width: var(--card-width);
    height: var(--card-height);
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 6px;
    cursor: grab;
    will-change: transform;
    transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.22);
    touch-action: none !important;
}
.card:active {
    cursor: grabbing;
}

.card.is-dragging {
    z-index: 99999 !important;
    opacity: 0.98;
    transition: none !important;
    filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.55));
}

/* Titreme Animasyonu (Geçersiz Tıklama Geri Bildirimi) */
@keyframes cardShake {
    0%, 100% { transform: translate3d(0, var(--card-top-offset, 0px), 0) rotate(0deg); }
    20% { transform: translate3d(-7px, var(--card-top-offset, 0px), 0) rotate(-4deg); }
    40% { transform: translate3d(7px, var(--card-top-offset, 0px), 0) rotate(4deg); }
    60% { transform: translate3d(-5px, var(--card-top-offset, 0px), 0) rotate(-2deg); }
    80% { transform: translate3d(5px, var(--card-top-offset, 0px), 0) rotate(2deg); }
}

.card.shake-invalid {
    animation: cardShake 0.38s ease-in-out !important;
}

.card-svg {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 6px;
    pointer-events: none;
    object-fit: fill;
}

.card-front.color-red {
    color: #dc2626;
}
.card-front.color-black {
    color: #1e293b;
}

.stock-count-badge {
    position: absolute;
    bottom: -6px;
    right: -6px;
    background: #020617;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.35);
    z-index: 10;
    pointer-events: none;
}

/* Yatay Ekran (Landscape Modu) */
@media (orientation: landscape) {
    .solitaire-container {
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "app-header app-header"
            "game-board game-board";
    }

    .game-board {
        flex-direction: row;
        align-items: flex-start;
        padding: 8px 16px;
    }

    .top-piles-row {
        flex-direction: column;
        width: auto;
        gap: 12px;
    }

    .stock-waste-group, .foundation-group {
        flex-direction: column;
    }

    .tableau-group {
        flex: 1;
    }
}
