/* ============================================================================
   KLONDIKE SOLITAIRE - STYLESHEET
   ============================================================================ */

/* CSS Variables */
:root {
    --primary-color: #16A34A;
    --primary-hover: #15803D;
    --secondary-color: #34D399;
    --bg-color: #f8fafc;
    --surface: #FFFFFF;
    --border-color: #e2e8f0;
    --text-primary: #1D1D1B;
    --text-secondary: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --card-green: #1a7f47;
    --card-green-dark: #0f5230;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Card dimensions */
    --card-width: 90px;
    --card-height: 126px;
    --card-radius: 8px;
    
    /* Spacing */
    --pile-gap: 10px;
    --tableau-offset-down: 20px;
    --tableau-offset-up: 35px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    :root {
        --card-width: 70px;
        --card-height: 98px;
        --card-radius: 6px;
        --pile-gap: 6px;
        --tableau-offset-down: 16px;
        --tableau-offset-up: 28px;
    }
}

/* ============================================================================
   BASE STYLES
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    background: radial-gradient(circle at 15% 15%, rgba(0, 153, 204, 0.12), transparent 55%),
                radial-gradient(circle at 85% 25%, rgba(0, 120, 180, 0.12), transparent 50%),
                linear-gradient(180deg, #0B1120 0%, #0F172A 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background image overlay */
body.solitaire-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--menu-bg-image, none);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.25;
    z-index: -1;
    pointer-events: none;
}

/* Gradient overlay */
body.solitaire-page::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 153, 204, 0.08) 0%, rgba(0, 191, 255, 0.1) 100%);
    z-index: -1;
    pointer-events: none;
}

/* ============================================================================
   GAME MENU CUSTOMIZATION (Solitaire)
   Override CSS variables for Solitaire theme - shared menu.css handles layout
   ============================================================================ */

body.solitaire-page.game-menu-active {
    --game-primary: #00BFFF;
    --game-primary-dark: #0099CC;
    --game-secondary: #FAB719;
    --menu-bg-image: url('/interactive/shared/backgrounds/solitaire.png');
}

/* Game-specific menu overrides - only what's needed beyond shared CSS */
.game-menu-screen.solitaire-menu {
    /* Any Solitaire-specific menu adjustments */
}

/* Ensure menu buttons are clickable */
.game-menu-screen.solitaire-menu .game-menu-button,
.game-menu-screen.solitaire-menu .qs-btn,
.game-menu-screen.solitaire-menu button {
    pointer-events: auto !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
}

/* Mobile menu styles are handled by shared game-menu.css */


/* ============================================================================
   HEADER
   ============================================================================ */

/* Old header - now hidden */
.header {
    background: var(--surface);
    border-bottom: 3px solid var(--primary-color);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-md);
}

/* Solitaire game info in shared header */
.solitaire-game-info {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-left: 2rem;
}

.solitaire-game-info .info-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
}

.solitaire-game-info .info-badge i {
    font-size: 1rem;
    opacity: 0.8;
}

.solitaire-game-info .difficulty-indicator {
    background: rgba(250, 183, 25, 0.2);
    border: 1px solid rgba(250, 183, 25, 0.5);
}

.solitaire-game-info .difficulty-indicator i {
    color: #FAB719;
}

/* Game control buttons in header */
.game-top-bar .game-control-btn {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.6);
}

.game-top-bar .game-control-btn:hover {
    background: #4CAF50;
    color: white;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-icon {
    padding: 0.5rem;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary {
    background: var(--text-secondary);
}

.btn-secondary:hover {
    background: #475569;
}

.btn-primary {
    background: var(--primary-color);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================================================
   GAME INFO BAR
   ============================================================================ */

.game-info-bar {
    background: rgba(255, 255, 255, 0.95);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.info-item i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.difficulty-badge {
    background: var(--secondary-color);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    color: var(--text-primary);
}

/* ============================================================================
   GAME BOARD
   ============================================================================ */

.game-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.game-board {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flex children to shrink */
    position: relative; /* For absolute positioning of dealing section */
}

/* Top Section: Foundations (Aces Up) */
.foundations-section {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem 0;
    padding-bottom: 0.5rem; /* Reduced bottom padding to bring tableau closer */
    flex-shrink: 0;
    margin-bottom: 0; /* No margin between foundations and tableau */
}

.foundations-group {
    display: flex;
    gap: var(--pile-gap);
    justify-content: center;
}

/* Middle Section: Tableau - positioned directly below foundations */
.tableau-section {
    display: flex;
    justify-content: center;
    gap: var(--pile-gap);
    flex: 1;
    align-items: flex-start;
    padding: 1rem 0;
    min-height: 0;
    overflow-y: auto; /* Allow scrolling if needed */
    margin-top: 0; /* Directly below foundations */
}

/* Bottom Section: Stock and Waste (Undealt Piles) - 10% from bottom */
.dealing-section {
    position: absolute;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 1rem 0;
    width: 100%;
    max-width: 1400px;
    pointer-events: none; /* Allow clicks to pass through container */
}

.dealing-group {
    display: flex;
    gap: var(--pile-gap);
    justify-content: center;
    align-items: flex-end;
    pointer-events: auto; /* Re-enable clicks on piles */
}

/* ============================================================================
   PILES
   ============================================================================ */

.pile {
    position: relative;
    width: var(--card-width);
    min-height: var(--card-height);
    cursor: pointer;
}

.pile-base {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--card-width);
    height: var(--card-height);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: var(--card-radius);
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    pointer-events: none;
}

/* Stock Pile */
.stock-pile {
    cursor: pointer;
}

.stock-pile .pile-base {
    cursor: pointer;
    pointer-events: none;
}

.stock-pile .pile-base:hover {
    background: rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.stock-pile.empty .pile-base {
    cursor: pointer;
    pointer-events: auto;
}

.stock-pile .card {
    pointer-events: none;
}

/* Foundation Bases */
.foundation-pile {
    pointer-events: auto;
}

.foundation-base {
    font-size: 2.5rem;
    font-weight: 700;
    pointer-events: none;
}

.foundation-pile:not(:has(.card)) .foundation-base {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.15);
}

/* Show suit symbols clearly when empty - hearts and diamonds red */
#foundation-0 .foundation-base {
    color: rgba(231, 76, 60, 0.5);
}

#foundation-1 .foundation-base {
    color: rgba(231, 76, 60, 0.5);
}

/* Clubs and spades black */
#foundation-2 .foundation-base {
    color: rgba(0, 0, 0, 0.4);
}

#foundation-3 .foundation-base {
    color: rgba(0, 0, 0, 0.4);
}

/* Tableau Bases */
.tableau-pile {
    pointer-events: auto;
}

.tableau-base {
    font-size: 2.5rem;
    font-weight: 700;
    pointer-events: none;
}

.tableau-pile {
    min-height: 500px;
}

.tableau-pile:not(:has(.card)) .tableau-base {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.15);
}

/* Valid drop target highlight */
.pile.valid-drop-target .pile-base {
    border-color: var(--success-color);
    border-style: solid;
    border-width: 3px;
    background: rgba(0, 153, 204, 0.1);
    box-shadow: 0 0 20px rgba(0, 153, 204, 0.3);
}

/* Invalid drop target */
.pile.invalid-drop-target .pile-base {
    border-color: var(--error-color);
    border-style: solid;
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ============================================================================
   CARDS - Clean implementation using SVG/PNG images
   ============================================================================ */

.card {
    position: absolute;
    width: var(--card-width);
    height: var(--card-height);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, top 0.3s ease, left 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: var(--shadow-md);
    border-radius: var(--card-radius);
    overflow: hidden; /* Ensure card content respects rounded corners */
    box-sizing: border-box; /* Ensure padding/border included in dimensions */
}

/* Ensure face cards maintain exact dimensions */
.card:has(.face-image) {
    width: var(--card-width) !important;
    height: var(--card-height) !important;
    min-width: var(--card-width) !important;
    min-height: var(--card-height) !important;
    max-width: var(--card-width) !important;
    max-height: var(--card-height) !important;
}

/* Card components - CSS card system */
.corner-top {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 10px;
    line-height: 1.1;
    font-family: 'Rockwell', 'Times New Roman', serif;
    font-weight: bold;
    pointer-events: none;
}

.corner-bottom {
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 10px;
    line-height: 1.1;
    transform: rotate(180deg);
    font-family: 'Rockwell', 'Times New Roman', serif;
    font-weight: bold;
    pointer-events: none;
}

/* Mobile corner sizing */
@media (max-width: 768px) {
    .corner-top, .corner-bottom {
        font-size: 8px;
    }
}

.center-symbols {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    font-size: 18px;
    position: relative;
    pointer-events: none;
}

/* Face cards - center-symbols container should fill entire card (override flex) */
.card:has(.face-image) .center-symbols {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    flex: none !important;
    flex-direction: normal !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    box-sizing: border-box !important;
    min-width: 100% !important;
    min-height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Suit colours */
.suit.hearts, .suit.diamonds {
    color: #e74c3c;
}

.suit.clubs, .suit.spades {
    color: #000;
}

/* Pips - positioned absolutely for proper layouts */
.pip {
    position: absolute;
    font-size: 1.0em;
    color: inherit;
    pointer-events: none;
}

/* Desktop Layout Adjustments */
@media (min-width: 769px) {
    /* Increase card sizes by 25% on desktop */
    :root {
        --card-width: 112.5px; /* 90px * 1.25 */
        --card-height: 157.5px; /* 126px * 1.25 */
        --card-radius: 10px; /* 8px * 1.25 */
    }
    
    .pip {
        font-size: 1.2em;
    }
    
    /* Move foundations to the right */
    .foundations-section {
        justify-content: flex-end;
        padding-right: 2rem;
        padding-left: 0;
    }
    
    /* Move undealt piles (stock/waste) to top left */
    .dealing-section {
        position: absolute;
        top: 2rem;
        left: 2rem;
        bottom: auto;
        transform: none;
        width: auto;
        max-width: none;
    }
    
    .dealing-group {
        justify-content: flex-start;
        align-items: flex-start;
    }
}

/* 2-card layout */
.card.hearts-2 .pip:nth-child(1), .card.diamonds-2 .pip:nth-child(1), 
.card.clubs-2 .pip:nth-child(1), .card.spades-2 .pip:nth-child(1) { 
    top: 8%; left: 50%; transform: translateX(-50%); 
}
.card.hearts-2 .pip:nth-child(2), .card.diamonds-2 .pip:nth-child(2),
.card.clubs-2 .pip:nth-child(2), .card.spades-2 .pip:nth-child(2) { 
    bottom: 8%; left: 50%; transform: translateX(-50%) rotate(180deg); 
}

/* 3-card layout */
.card.hearts-3 .pip:nth-child(1), .card.diamonds-3 .pip:nth-child(1),
.card.clubs-3 .pip:nth-child(1), .card.spades-3 .pip:nth-child(1) { 
    top: 8%; left: 50%; transform: translateX(-50%); 
}
.card.hearts-3 .pip:nth-child(2), .card.diamonds-3 .pip:nth-child(2),
.card.clubs-3 .pip:nth-child(2), .card.spades-3 .pip:nth-child(2) { 
    top: 50%; left: 50%; transform: translate(-50%, -50%); 
}
.card.hearts-3 .pip:nth-child(3), .card.diamonds-3 .pip:nth-child(3),
.card.clubs-3 .pip:nth-child(3), .card.spades-3 .pip:nth-child(3) { 
    bottom: 8%; left: 50%; transform: translateX(-50%) rotate(180deg); 
}

/* 4-card layout */
.card.hearts-4 .pip:nth-child(1), .card.diamonds-4 .pip:nth-child(1),
.card.clubs-4 .pip:nth-child(1), .card.spades-4 .pip:nth-child(1) { 
    top: 8%; left: 25%; transform: translateX(-50%); 
}
.card.hearts-4 .pip:nth-child(2), .card.diamonds-4 .pip:nth-child(2),
.card.clubs-4 .pip:nth-child(2), .card.spades-4 .pip:nth-child(2) { 
    top: 8%; left: 75%; transform: translateX(-50%); 
}
.card.hearts-4 .pip:nth-child(3), .card.diamonds-4 .pip:nth-child(3),
.card.clubs-4 .pip:nth-child(3), .card.spades-4 .pip:nth-child(3) { 
    bottom: 8%; left: 25%; transform: translateX(-50%) rotate(180deg); 
}
.card.hearts-4 .pip:nth-child(4), .card.diamonds-4 .pip:nth-child(4),
.card.clubs-4 .pip:nth-child(4), .card.spades-4 .pip:nth-child(4) { 
    bottom: 8%; left: 75%; transform: translateX(-50%) rotate(180deg); 
}

/* 5-card layout */
.card.hearts-5 .pip:nth-child(1), .card.diamonds-5 .pip:nth-child(1),
.card.clubs-5 .pip:nth-child(1), .card.spades-5 .pip:nth-child(1) { 
    top: 8%; left: 25%; transform: translateX(-50%); 
}
.card.hearts-5 .pip:nth-child(2), .card.diamonds-5 .pip:nth-child(2),
.card.clubs-5 .pip:nth-child(2), .card.spades-5 .pip:nth-child(2) { 
    top: 8%; left: 75%; transform: translateX(-50%); 
}
.card.hearts-5 .pip:nth-child(3), .card.diamonds-5 .pip:nth-child(3),
.card.clubs-5 .pip:nth-child(3), .card.spades-5 .pip:nth-child(3) { 
    top: 50%; left: 50%; transform: translate(-50%, -50%); 
}
.card.hearts-5 .pip:nth-child(4), .card.diamonds-5 .pip:nth-child(4),
.card.clubs-5 .pip:nth-child(4), .card.spades-5 .pip:nth-child(4) { 
    bottom: 8%; left: 25%; transform: translateX(-50%) rotate(180deg); 
}
.card.hearts-5 .pip:nth-child(5), .card.diamonds-5 .pip:nth-child(5),
.card.clubs-5 .pip:nth-child(5), .card.spades-5 .pip:nth-child(5) { 
    bottom: 8%; left: 75%; transform: translateX(-50%) rotate(180deg); 
}

/* 6-card layout */
.card.hearts-6 .pip:nth-child(1), .card.diamonds-6 .pip:nth-child(1),
.card.clubs-6 .pip:nth-child(1), .card.spades-6 .pip:nth-child(1) { 
    top: 8%; left: 25%; transform: translateX(-50%); 
}
.card.hearts-6 .pip:nth-child(2), .card.diamonds-6 .pip:nth-child(2),
.card.clubs-6 .pip:nth-child(2), .card.spades-6 .pip:nth-child(2) { 
    top: 8%; left: 75%; transform: translateX(-50%); 
}
.card.hearts-6 .pip:nth-child(3), .card.diamonds-6 .pip:nth-child(3),
.card.clubs-6 .pip:nth-child(3), .card.spades-6 .pip:nth-child(3) { 
    top: 50%; left: 25%; transform: translate(-50%, -50%); 
}
.card.hearts-6 .pip:nth-child(4), .card.diamonds-6 .pip:nth-child(4),
.card.clubs-6 .pip:nth-child(4), .card.spades-6 .pip:nth-child(4) { 
    top: 50%; left: 75%; transform: translate(-50%, -50%); 
}
.card.hearts-6 .pip:nth-child(5), .card.diamonds-6 .pip:nth-child(5),
.card.clubs-6 .pip:nth-child(5), .card.spades-6 .pip:nth-child(5) { 
    bottom: 8%; left: 25%; transform: translateX(-50%) rotate(180deg); 
}
.card.hearts-6 .pip:nth-child(6), .card.diamonds-6 .pip:nth-child(6),
.card.clubs-6 .pip:nth-child(6), .card.spades-6 .pip:nth-child(6) { 
    bottom: 8%; left: 75%; transform: translateX(-50%) rotate(180deg); 
}

/* 7-card layout */
.card.hearts-7 .pip:nth-child(1), .card.diamonds-7 .pip:nth-child(1),
.card.clubs-7 .pip:nth-child(1), .card.spades-7 .pip:nth-child(1) { 
    top: 8%; left: 25%; transform: translateX(-50%); 
}
.card.hearts-7 .pip:nth-child(2), .card.diamonds-7 .pip:nth-child(2),
.card.clubs-7 .pip:nth-child(2), .card.spades-7 .pip:nth-child(2) { 
    top: 8%; left: 75%; transform: translateX(-50%); 
}
.card.hearts-7 .pip:nth-child(3), .card.diamonds-7 .pip:nth-child(3),
.card.clubs-7 .pip:nth-child(3), .card.spades-7 .pip:nth-child(3) { 
    top: 50%; left: 25%; transform: translate(-50%, -50%); 
}
.card.hearts-7 .pip:nth-child(4), .card.diamonds-7 .pip:nth-child(4),
.card.clubs-7 .pip:nth-child(4), .card.spades-7 .pip:nth-child(4) { 
    top: 50%; left: 75%; transform: translate(-50%, -50%); 
}
.card.hearts-7 .pip:nth-child(5), .card.diamonds-7 .pip:nth-child(5),
.card.clubs-7 .pip:nth-child(5), .card.spades-7 .pip:nth-child(5) { 
    top: 35%; left: 50%; transform: translate(-50%, -50%); 
}
.card.hearts-7 .pip:nth-child(6), .card.diamonds-7 .pip:nth-child(6),
.card.clubs-7 .pip:nth-child(6), .card.spades-7 .pip:nth-child(6) { 
    bottom: 8%; left: 25%; transform: translateX(-50%) rotate(180deg); 
}
.card.hearts-7 .pip:nth-child(7), .card.diamonds-7 .pip:nth-child(7),
.card.clubs-7 .pip:nth-child(7), .card.spades-7 .pip:nth-child(7) { 
    bottom: 8%; left: 75%; transform: translateX(-50%) rotate(180deg); 
}

/* 8-card layout */
.card.hearts-8 .pip:nth-child(1), .card.diamonds-8 .pip:nth-child(1),
.card.clubs-8 .pip:nth-child(1), .card.spades-8 .pip:nth-child(1) { 
    top: 8%; left: 25%; transform: translateX(-50%); 
}
.card.hearts-8 .pip:nth-child(2), .card.diamonds-8 .pip:nth-child(2),
.card.clubs-8 .pip:nth-child(2), .card.spades-8 .pip:nth-child(2) { 
    top: 8%; left: 75%; transform: translateX(-50%); 
}
.card.hearts-8 .pip:nth-child(3), .card.diamonds-8 .pip:nth-child(3),
.card.clubs-8 .pip:nth-child(3), .card.spades-8 .pip:nth-child(3) { 
    top: 50%; left: 25%; transform: translate(-50%, -50%); 
}
.card.hearts-8 .pip:nth-child(4), .card.diamonds-8 .pip:nth-child(4),
.card.clubs-8 .pip:nth-child(4), .card.spades-8 .pip:nth-child(4) { 
    top: 50%; left: 75%; transform: translate(-50%, -50%); 
}
.card.hearts-8 .pip:nth-child(5), .card.diamonds-8 .pip:nth-child(5),
.card.clubs-8 .pip:nth-child(5), .card.spades-8 .pip:nth-child(5) { 
    top: 35%; left: 50%; transform: translate(-50%, -50%); 
}
.card.hearts-8 .pip:nth-child(6), .card.diamonds-8 .pip:nth-child(6),
.card.clubs-8 .pip:nth-child(6), .card.spades-8 .pip:nth-child(6) { 
    bottom: 8%; left: 25%; transform: translateX(-50%) rotate(180deg); 
}
.card.hearts-8 .pip:nth-child(7), .card.diamonds-8 .pip:nth-child(7),
.card.clubs-8 .pip:nth-child(7), .card.spades-8 .pip:nth-child(7) { 
    bottom: 8%; left: 75%; transform: translateX(-50%) rotate(180deg); 
}
.card.hearts-8 .pip:nth-child(8), .card.diamonds-8 .pip:nth-child(8),
.card.clubs-8 .pip:nth-child(8), .card.spades-8 .pip:nth-child(8) { 
    bottom: 35%; left: 50%; transform: translate(-50%, 50%) rotate(180deg); 
}

/* 9-card layout */
.card.hearts-9 .pip:nth-child(1), .card.diamonds-9 .pip:nth-child(1),
.card.clubs-9 .pip:nth-child(1), .card.spades-9 .pip:nth-child(1) { 
    top: 8%; left: 25%; transform: translateX(-50%); 
}
.card.hearts-9 .pip:nth-child(2), .card.diamonds-9 .pip:nth-child(2),
.card.clubs-9 .pip:nth-child(2), .card.spades-9 .pip:nth-child(2) { 
    top: 8%; left: 75%; transform: translateX(-50%); 
}
.card.hearts-9 .pip:nth-child(3), .card.diamonds-9 .pip:nth-child(3),
.card.clubs-9 .pip:nth-child(3), .card.spades-9 .pip:nth-child(3) { 
    top: 42%; left: 25%; transform: translate(-50%, -50%); 
}
.card.hearts-9 .pip:nth-child(4), .card.diamonds-9 .pip:nth-child(4),
.card.clubs-9 .pip:nth-child(4), .card.spades-9 .pip:nth-child(4) { 
    top: 42%; left: 75%; transform: translate(-50%, -50%); 
}
.card.hearts-9 .pip:nth-child(5), .card.diamonds-9 .pip:nth-child(5),
.card.clubs-9 .pip:nth-child(5), .card.spades-9 .pip:nth-child(5) { 
    top: 58%; left: 25%; transform: translate(-50%, -50%) rotate(180deg); 
}
.card.hearts-9 .pip:nth-child(6), .card.diamonds-9 .pip:nth-child(6),
.card.clubs-9 .pip:nth-child(6), .card.spades-9 .pip:nth-child(6) { 
    top: 58%; left: 75%; transform: translate(-50%, -50%) rotate(180deg); 
}
.card.hearts-9 .pip:nth-child(7), .card.diamonds-9 .pip:nth-child(7),
.card.clubs-9 .pip:nth-child(7), .card.spades-9 .pip:nth-child(7) { 
    bottom: 8%; left: 25%; transform: translateX(-50%) rotate(180deg); 
}
.card.hearts-9 .pip:nth-child(8), .card.diamonds-9 .pip:nth-child(8),
.card.clubs-9 .pip:nth-child(8), .card.spades-9 .pip:nth-child(8) { 
    bottom: 8%; left: 75%; transform: translateX(-50%) rotate(180deg); 
}
.card.hearts-9 .pip:nth-child(9), .card.diamonds-9 .pip:nth-child(9),
.card.clubs-9 .pip:nth-child(9), .card.spades-9 .pip:nth-child(9) { 
    top: 50%; left: 50%; transform: translate(-50%, -50%); 
}

/* 10-card layout */
.card.hearts-10 .pip:nth-child(1), .card.diamonds-10 .pip:nth-child(1),
.card.clubs-10 .pip:nth-child(1), .card.spades-10 .pip:nth-child(1) { 
    top: 8%; left: 25%; transform: translateX(-50%); 
}
.card.hearts-10 .pip:nth-child(2), .card.diamonds-10 .pip:nth-child(2),
.card.clubs-10 .pip:nth-child(2), .card.spades-10 .pip:nth-child(2) { 
    top: 8%; left: 75%; transform: translateX(-50%); 
}
.card.hearts-10 .pip:nth-child(3), .card.diamonds-10 .pip:nth-child(3),
.card.clubs-10 .pip:nth-child(3), .card.spades-10 .pip:nth-child(3) { 
    top: 42%; left: 25%; transform: translate(-50%, -50%); 
}
.card.hearts-10 .pip:nth-child(4), .card.diamonds-10 .pip:nth-child(4),
.card.clubs-10 .pip:nth-child(4), .card.spades-10 .pip:nth-child(4) { 
    top: 42%; left: 75%; transform: translate(-50%, -50%); 
}
.card.hearts-10 .pip:nth-child(5), .card.diamonds-10 .pip:nth-child(5),
.card.clubs-10 .pip:nth-child(5), .card.spades-10 .pip:nth-child(5) { 
    top: 58%; left: 25%; transform: translate(-50%, -50%) rotate(180deg); 
}
.card.hearts-10 .pip:nth-child(6), .card.diamonds-10 .pip:nth-child(6),
.card.clubs-10 .pip:nth-child(6), .card.spades-10 .pip:nth-child(6) { 
    top: 58%; left: 75%; transform: translate(-50%, -50%) rotate(180deg); 
}
.card.hearts-10 .pip:nth-child(7), .card.diamonds-10 .pip:nth-child(7),
.card.clubs-10 .pip:nth-child(7), .card.spades-10 .pip:nth-child(7) { 
    bottom: 8%; left: 25%; transform: translateX(-50%) rotate(180deg); 
}
.card.hearts-10 .pip:nth-child(8), .card.diamonds-10 .pip:nth-child(8),
.card.clubs-10 .pip:nth-child(8), .card.spades-10 .pip:nth-child(8) { 
    bottom: 8%; left: 75%; transform: translateX(-50%) rotate(180deg); 
}
.card.hearts-10 .pip:nth-child(9), .card.diamonds-10 .pip:nth-child(9),
.card.clubs-10 .pip:nth-child(9), .card.spades-10 .pip:nth-child(9) { 
    top: 29%; left: 50%; transform: translate(-50%, -50%); 
}
.card.hearts-10 .pip:nth-child(10), .card.diamonds-10 .pip:nth-child(10),
.card.clubs-10 .pip:nth-child(10), .card.spades-10 .pip:nth-child(10) { 
    bottom: 29%; left: 50%; transform: translate(-50%, 50%) rotate(180deg); 
}

/* Face images fill entire card with cropping - highest priority */
.face-image,
img.face-image,
.card .face-image,
.card img.face-image,
.card:has(.face-image) .face-image,
.card:has(.face-image) img.face-image,
.center-symbols .face-image,
.center-symbols img.face-image,
.card[style*="overflow: hidden"] .face-image,
.card[style*="overflow: hidden"] img.face-image {
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center !important;
    border-radius: var(--card-radius) !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 1 !important;
    display: block !important;
    box-sizing: border-box !important;
}


/* Ace symbols using data attributes */
.center-symbols[data-suit="hearts"]::before {
    content: "♥";
    color: #e74c3c;
    font-size: 2.5em;
    display: block;
}

.center-symbols[data-suit="diamonds"]::before {
    content: "♦";
    color: #e74c3c;
    font-size: 2.5em;
    display: block;
}

.center-symbols[data-suit="clubs"]::before {
    content: "♣";
    color: #000;
    font-size: 2.5em;
    display: block;
}

.center-symbols[data-suit="spades"]::before {
    content: "♠";
    color: #000;
    font-size: 2.5em;
    display: block;
}

/* Responsive Ace symbols for mobile */
@media (max-width: 768px) {
    .center-symbols[data-suit]::before {
        font-size: 1.8em;
    }
}

/* Card back */
.card-back {
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    padding: 0 !important;
    border-radius: var(--card-radius);
}

/* Card images (face cards) - default, overridden by face-image rules above */
.card img:not(.face-image) {
    border-radius: var(--card-radius);
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Face images - ensure these rules override everything else */
img.face-image,
.card img.face-image,
.card:has(.face-image) img.face-image,
.center-symbols img.face-image {
    /* All rules are defined at line 862+ with !important flags */
    /* This empty rule ensures specificity for img.face-image selector */
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.card.selected {
    box-shadow: 0 0 20px rgba(250, 183, 25, 0.8);
    z-index: 100;
}

.card.dragging {
    opacity: 0.8;
    z-index: 1000;
    cursor: grabbing;
    transform: scale(1.05);
}

.card.animating {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                top 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Face-down cards */
.card.face-down {
    cursor: default;
}

.card.face-down:hover {
    transform: none;
    box-shadow: var(--shadow-md);
}

/* Flip animation */
.card.flipping {
    animation: cardFlip 0.6s ease;
}

@keyframes cardFlip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}

/* Hint highlight */
.card.hint-highlight {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(250, 183, 25, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(250, 183, 25, 0);
    }
}

/* ============================================================================
   MODALS
   ============================================================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-large {
    max-width: 800px;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    transition: all 0.3s ease;
}

.modal-close:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 2px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Settings */
.setting-group {
    margin-bottom: 1rem;
}

.setting-group label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 0.5rem;
    transition: background 0.3s ease;
}

.setting-group label:hover {
    background: var(--bg-color);
}

.setting-group input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 0.5rem;
    text-align: center;
    border: 2px solid var(--border-color);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.difficulty-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.difficulty-stat-row {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 0.5rem;
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 1rem;
    align-items: center;
}

.difficulty-name {
    font-weight: 700;
    color: var(--primary-color);
}

.difficulty-data {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
}

/* Help sections */
.help-section {
    margin-bottom: 2rem;
}

.help-section h3 {
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.help-section ul {
    list-style: none;
    padding-left: 0;
}

.help-section li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.help-section li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: 700;
}

/* Win modal */
.win-celebration {
    text-align: center;
    margin-bottom: 2rem;
}

.win-icon {
    font-size: 5rem;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.win-message {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: 1rem;
}

.win-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.win-stat {
    background: var(--bg-color);
    padding: 1.5rem 1rem;
    border-radius: 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.win-stat i {
    font-size: 2rem;
    color: var(--primary-color);
}

.win-stat strong {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.win-stat span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 1024px) {
    .tableau-section {
        gap: calc(var(--pile-gap) * 0.8);
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    /* Stack or hide game info on mobile */
    .solitaire-game-info {
        display: none; /* Hide in mobile menu, shown in drawer instead */
    }
    
    .header-buttons {
        width: 100%;
        justify-content: space-between;
    }
    
    .game-info-bar {
        padding: 0.5rem 1rem;
        gap: 1rem;
        font-size: 0.875rem;
    }
    
    .game-board {
        padding: 1rem 0.5rem;
    }
    
    .foundations-section {
        padding: 0.5rem 0;
        justify-content: center;
    }
    
    .foundations-group {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .tableau-section {
        overflow-x: auto;
        overflow-y: auto;
        justify-content: flex-start;
        padding: 0.5rem 0.5rem;
        align-items: flex-start;
        margin-top: calc(var(--card-height) * 2); /* 2x card height from top on mobile too */
    }
    
    .tableau-pile {
        min-height: auto; /* Remove fixed min-height */
    }
    
    .dealing-section {
        bottom: 10%; /* 10% from bottom on mobile too */
        padding: 0.5rem 0;
        width: calc(100% - 1rem); /* Account for padding */
    }
    
    .dealing-group {
        justify-content: center;
        align-items: flex-end; /* Align to bottom on mobile */
    }
    
    .win-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1rem;
    }
    
    .btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }
    
    .btn-icon {
        padding: 0.4rem;
    }
    
    .game-info-bar {
        font-size: 0.75rem;
        gap: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .pile-base {
        border-width: 3px;
        border-style: solid;
    }
    
    .card {
        border: 2px solid #000;
    }
}

/* ============================================================================
   AUTO-COMPLETE CELEBRATION ANIMATION
   ============================================================================ */

.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.card-burst {
    position: absolute;
    width: 40px;
    height: 56px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    animation: card-burst 2s ease-out forwards;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

@keyframes card-burst {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) rotate(var(--rotate)) scale(0.5);
        opacity: 0;
    }
}

/* ============================================================================
   LOADING & EMPTY STATES
   ============================================================================ */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    font-size: 1.25rem;
    color: white;
}

.loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }


