/* Card Probability Simulation Styles - MathsVault Design System */

/* Import the existing playing cards CSS */
@import url('/assets/css_graphics/full_deck/playing_cards.css');


:root {
    --primary: #C90C0F;
    --secondary: #FAB719;
    --light: #FFFFFF;
    --dark: #1D1D1B;
    --gray: #6c757d;
    --light-gray: #f8f9fa;
    --border: #dee2e6;
    --shadow: 0 4px 15px rgba(0,0,0,0.1);
    --card-shadow: 0 2px 8px rgba(0,0,0,0.15);
    --card-border-radius: 8px;
}

/* Main container styling */
.container {
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    color: var(--dark);
    line-height: 1.6;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.container h1 {
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    color: var(--primary);
    font-weight: bold;
    text-align: center;
    margin-bottom: 1rem;
    font-size: 2.5rem;
}

.container h1 i {
    margin-right: 0.5rem;
    color: var(--secondary);
}

.container h2,
.container h3,
.container h4 {
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    color: var(--primary);
    text-transform: capitalize;
}

/* Simulation area */
.simulation-area {
    background: var(--light);
    border: 3px solid var(--primary);
    border-radius: 16px;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: var(--shadow);
}

/* Controls */
.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--light-gray);
    border-radius: 12px;
    border: 2px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-weight: bold;
    color: var(--primary);
    font-size: 1rem;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

.control-group select,
.control-group input {
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: var(--light);
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    transition: all 0.3s ease;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(201, 12, 15, 0.1);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

.btn-primary:hover {
    background: #a00a0c;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-secondary {
    background: var(--gray);
    color: var(--light);
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Deck display */
.deck-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #2D7A4A, #1F5F3A);
    border-radius: 12px;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
}

.deck-display::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at center, transparent 0%, transparent 60%, rgba(0, 0, 0, 0.1) 100%);
    border-radius: 12px;
    pointer-events: none;
    z-index: 0;
}

/* Full deck display - separate section at bottom */
.full-deck-display {
    margin: 2rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #2D7A4A, #1F5F3A);
    border-radius: 12px;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.full-deck-display::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at center, transparent 0%, transparent 60%, rgba(0, 0, 0, 0.1) 100%);
    border-radius: 12px;
    pointer-events: none;
    z-index: 0;
}

.full-deck-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
    z-index: 1;
}

.full-deck {
    position: relative;
    height: 120px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.full-deck .card {
    position: absolute;
    width: 60px;
    height: 84px;
    border: 1px solid #666; /* Hairline grey stroke */
    border-radius: 8px;
    background: #fff;
    box-shadow: 
        1px 1px 3px rgba(0,0,0,0.2),
        2px 2px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3px;
    font-family: 'Rockwell', 'Times New Roman', serif;
    font-weight: bold;
    font-size: 8px;
    transition: all 1s ease;
    cursor: pointer;
    z-index: 1;
}

.full-deck .card:hover {
    transform: translateY(-5px) scale(1.05);
    z-index: 10;
}

.full-deck .card.winning-card {
    transform: translateY(-42px);
    box-shadow: 
        0 8px 16px rgba(0,0,0,0.3),
        0 4px 8px rgba(0,0,0,0.2);
    border: 2px solid #28a745;
}


/* Face image styling for full deck (default - overridden by deck-specific rules below) */
.full-deck .face-image {
    width: 85% !important;
    height: 85% !important;
    object-fit: contain !important;
    border-radius: 4px !important;
    display: block !important;
    z-index: 1 !important;
    position: relative !important;
    margin: auto !important;
}

/* Greyhounds deck - images fill entire card with no border (full deck only) */
.full-deck .Greyhounds_and_Friends .face-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: var(--card-border-radius) !important;
    display: block !important;
    z-index: 1 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
}

/* Mathematicians deck - images scaled to 95% with border (full deck only) */
.full-deck .mathematicians .face-image {
    width: 95% !important;
    height: 95% !important;
    object-fit: contain !important;
    border-radius: var(--card-border-radius) !important;
    display: block !important;
    z-index: 1 !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    filter: grayscale(100%);
    border: 1px solid white;
    box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.1);
}

/* Greyhounds deck - picture cards fill entire card with 0% margin */
.picked-cards .Greyhounds_and_Friends .face-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: var(--card-border-radius) !important;
    display: block !important;
    z-index: 1 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
}

/* Greyhounds deck - remove card border for picture cards */
.picked-cards .card.Greyhounds_and_Friends.has-face-image {
    border: none !important;
    padding: 0 !important;
}


/* Mathematicians deck - images scaled to 95% with border (picked cards) */
.picked-cards .mathematicians .face-image {
    width: 95% !important;
    height: 95% !important;
    object-fit: contain !important;
    border-radius: var(--card-border-radius) !important;
    display: block !important;
    z-index: 1 !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    filter: grayscale(100%);
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Mathematicians deck - remove card border for picture cards */
.picked-cards .card.mathematicians.has-face-image {
    border: none !important;
    padding: 0 !important;
}

/* Mathematicians deck - mathematician name overlay */
.picked-cards .card.mathematicians .mathematician-name {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Rockwell', 'Times New Roman', serif;
    font-weight: bold;
    font-size: 14px;
    text-align: center;
    text-shadow: 
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white,
        0 0 2px white;
    -webkit-text-stroke: 0.5px white;
    z-index: 10;
    max-width: 90%;
    word-wrap: break-word;
}

/* Mathematicians deck - red color for hearts and diamonds names */
.picked-cards .card.mathematicians.hearts-A .mathematician-name,
.picked-cards .card.mathematicians.hearts-J .mathematician-name,
.picked-cards .card.mathematicians.hearts-Q .mathematician-name,
.picked-cards .card.mathematicians.hearts-K .mathematician-name,
.picked-cards .card.mathematicians.diamonds-A .mathematician-name,
.picked-cards .card.mathematicians.diamonds-J .mathematician-name,
.picked-cards .card.mathematicians.diamonds-Q .mathematician-name,
.picked-cards .card.mathematicians.diamonds-K .mathematician-name {
    color: #e74c3c;
}

/* Mathematicians deck - black color for clubs and spades names */
.picked-cards .card.mathematicians.clubs-A .mathematician-name,
.picked-cards .card.mathematicians.clubs-J .mathematician-name,
.picked-cards .card.mathematicians.clubs-Q .mathematician-name,
.picked-cards .card.mathematicians.clubs-K .mathematician-name,
.picked-cards .card.mathematicians.spades-A .mathematician-name,
.picked-cards .card.mathematicians.spades-J .mathematician-name,
.picked-cards .card.mathematicians.spades-Q .mathematician-name,
.picked-cards .card.mathematicians.spades-K .mathematician-name {
    color: #000;
}

/* Mathematicians deck - joker name styling with raised position */
.picked-cards .card.mathematicians.joker_red .mathematician-name {
    color: #e74c3c; /* Red for red joker */
    bottom: 35px; /* Raised 5% from default 20px position */
}

.picked-cards .card.mathematicians.joker_black .mathematician-name {
    color: #000; /* Black for black joker */
    bottom: 35px; /* Raised 5% from default 20px position */
}

/* Mathematicians deck - full deck mathematician name overlay */
.full-deck .card.mathematicians .mathematician-name {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Rockwell', 'Times New Roman', serif;
    font-weight: bold;
    font-size: 8px;
    text-align: center;
    text-shadow: 
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white,
        0 0 2px white;
    -webkit-text-stroke: 0.5px white;
    z-index: 10;
    max-width: 90%;
    word-wrap: break-word;
}

/* Mathematicians deck - full deck red color for hearts and diamonds names */
.full-deck .card.mathematicians.hearts-A .mathematician-name,
.full-deck .card.mathematicians.hearts-J .mathematician-name,
.full-deck .card.mathematicians.hearts-Q .mathematician-name,
.full-deck .card.mathematicians.hearts-K .mathematician-name,
.full-deck .card.mathematicians.diamonds-A .mathematician-name,
.full-deck .card.mathematicians.diamonds-J .mathematician-name,
.full-deck .card.mathematicians.diamonds-Q .mathematician-name,
.full-deck .card.mathematicians.diamonds-K .mathematician-name {
    color: #e74c3c;
}

/* Mathematicians deck - full deck black color for clubs and spades names */
.full-deck .card.mathematicians.clubs-A .mathematician-name,
.full-deck .card.mathematicians.clubs-J .mathematician-name,
.full-deck .card.mathematicians.clubs-Q .mathematician-name,
.full-deck .card.mathematicians.clubs-K .mathematician-name,
.full-deck .card.mathematicians.spades-A .mathematician-name,
.full-deck .card.mathematicians.spades-J .mathematician-name,
.full-deck .card.mathematicians.spades-Q .mathematician-name,
.full-deck .card.mathematicians.spades-K .mathematician-name {
    color: #000;
}

/* Mathematicians deck - full deck joker name styling with raised position */
.full-deck .card.mathematicians.joker_red .mathematician-name {
    color: #e74c3c; /* Red for red joker */
    bottom: 15px; /* Raised 5% from default 8px position */
}

.full-deck .card.mathematicians.joker_black .mathematician-name {
    color: #000; /* Black for black joker */
    bottom: 15px; /* Raised 5% from default 8px position */
}

/* Animation for deck compression and joker insertion */
@keyframes deckCompress {
    0% {
        transform: scale(1) translateX(0) rotate(var(--card-rotation, 0deg));
    }
    50% {
        transform: scale(0.995) translateX(var(--compress-offset, 0px)) rotate(var(--card-rotation, 0deg));
    }
    100% {
        transform: scale(0.99) translateX(var(--compress-offset, 0px)) rotate(var(--card-rotation, 0deg));
    }
}

@keyframes jokerFall {
    0% {
        transform: translateY(-120px) scale(1.3) rotate(var(--joker-rotation, 0deg));
        opacity: 0;
    }
    30% {
        transform: translateY(-60px) scale(1.15) rotate(var(--joker-rotation, 0deg));
        opacity: 0.6;
    }
    70% {
        transform: translateY(-20px) scale(1.05) rotate(var(--joker-rotation, 0deg));
        opacity: 0.9;
    }
    100% {
        transform: translateY(0) scale(1) rotate(var(--joker-rotation, 0deg));
        opacity: 1;
    }
}

@keyframes deckExpand {
    0% {
        transform: scale(0.99) translateX(var(--compress-offset, 0px)) rotate(var(--card-rotation, 0deg));
    }
    100% {
        transform: scale(1) translateX(0) rotate(var(--card-rotation, 0deg));
    }
}

/* Animation classes */
.full-deck .card.compressing {
    animation: deckCompress 1s ease-in-out forwards;
}

.full-deck .card.expanding {
    animation: deckExpand 1s ease-in-out forwards;
}

.full-deck .card.joker-falling {
    animation: jokerFall 1s ease-out forwards;
    /* Animation delay is set dynamically in JavaScript */
}

/* Mathematicians deck - red color for hearts and diamonds corner text and symbols */
.picked-cards .card.mathematicians.hearts-A .corner-top,
.picked-cards .card.mathematicians.hearts-A .corner-bottom,
.picked-cards .card.mathematicians.hearts-J .corner-top,
.picked-cards .card.mathematicians.hearts-J .corner-bottom,
.picked-cards .card.mathematicians.hearts-Q .corner-top,
.picked-cards .card.mathematicians.hearts-Q .corner-bottom,
.picked-cards .card.mathematicians.hearts-K .corner-top,
.picked-cards .card.mathematicians.hearts-K .corner-bottom,
.picked-cards .card.mathematicians.diamonds-A .corner-top,
.picked-cards .card.mathematicians.diamonds-A .corner-bottom,
.picked-cards .card.mathematicians.diamonds-J .corner-top,
.picked-cards .card.mathematicians.diamonds-J .corner-bottom,
.picked-cards .card.mathematicians.diamonds-Q .corner-top,
.picked-cards .card.mathematicians.diamonds-Q .corner-bottom,
.picked-cards .card.mathematicians.diamonds-K .corner-top,
.picked-cards .card.mathematicians.diamonds-K .corner-bottom {
    color: #e74c3c !important;
}

/* Mathematicians deck - red color for full deck hearts and diamonds corner text and symbols */
.full-deck .card.mathematicians.hearts-A .corner-top,
.full-deck .card.mathematicians.hearts-A .corner-bottom,
.full-deck .card.mathematicians.hearts-J .corner-top,
.full-deck .card.mathematicians.hearts-J .corner-bottom,
.full-deck .card.mathematicians.hearts-Q .corner-top,
.full-deck .card.mathematicians.hearts-Q .corner-bottom,
.full-deck .card.mathematicians.hearts-K .corner-top,
.full-deck .card.mathematicians.hearts-K .corner-bottom,
.full-deck .card.mathematicians.diamonds-A .corner-top,
.full-deck .card.mathematicians.diamonds-A .corner-bottom,
.full-deck .card.mathematicians.diamonds-J .corner-top,
.full-deck .card.mathematicians.diamonds-J .corner-bottom,
.full-deck .card.mathematicians.diamonds-Q .corner-top,
.full-deck .card.mathematicians.diamonds-Q .corner-bottom,
.full-deck .card.mathematicians.diamonds-K .corner-top,
.full-deck .card.mathematicians.diamonds-K .corner-bottom {
    color: #e74c3c !important;
}


/* Greyhounds deck - ensure center-symbols work properly for pseudo-elements */
.picked-cards .card.Greyhounds_and_Friends .center-symbols {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
    font-size: 36px !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Mathematicians deck - ensure center-symbols work properly for pseudo-elements */
.picked-cards .card.mathematicians .center-symbols {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
    font-size: 36px !important;
    position: relative !important;
    z-index: 1 !important;
}



/* Ace of Spades - disable pseudo-elements (uses PNG image) */
.picked-cards .card.spades-A .center-symbols::before,
.picked-cards .card.spades-A .center-symbols::after,
.full-deck .card.spades-A .center-symbols::before,
.full-deck .card.spades-A .center-symbols::after {
    display: none !important;
}

/* Ace of Spades - now uses dynamic image loading */

/* Pip styling for interactive cards - override base CSS */
.picked-cards .pip {
    font-size: 1.08em !important; /* 10% smaller than 1.2em - proportional pip size */
    text-shadow: 
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white,
        0 0 2px white;
    -webkit-text-stroke: 0.5px white;
}

.full-deck .pip {
    font-size: 2.1em !important; /* Match main playing cards - 75% increase from 1.2em */
    text-shadow: 
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white,
        0 0 2px white;
    -webkit-text-stroke: 0.5px white;
}

/* Hide regular pips for ace cards - only show the large centered pip */
.picked-cards .card.hearts-A .pip,
.picked-cards .card.diamonds-A .pip,
.picked-cards .card.clubs-A .pip,
.full-deck .card.hearts-A .pip,
.full-deck .card.diamonds-A .pip,
.full-deck .card.clubs-A .pip {
    display: none !important;
}

/* Ace pips - 100% larger than regular pips, centered */
.picked-cards .card.hearts-A .center-symbols::before,
.picked-cards .card.diamonds-A .center-symbols::before,
.picked-cards .card.clubs-A .center-symbols::before,
.full-deck .card.hearts-A .center-symbols::before,
.full-deck .card.diamonds-A .center-symbols::before,
.full-deck .card.clubs-A .center-symbols::before {
    font-size: 2.1em !important; /* Match main pip size */
    display: block !important;
}

/* Ace symbols using data attributes */
.picked-cards .center-symbols[data-suit="hearts"]::before,
.full-deck .center-symbols[data-suit="hearts"]::before {
    content: "♥";
    color: #e74c3c;
    font-size: 2.1em !important;
    display: block !important;
}

.picked-cards .center-symbols[data-suit="diamonds"]::before,
.full-deck .center-symbols[data-suit="diamonds"]::before {
    content: "♦";
    color: #e74c3c;
    font-size: 2.1em !important;
    display: block !important;
}

.picked-cards .center-symbols[data-suit="clubs"]::before,
.full-deck .center-symbols[data-suit="clubs"]::before {
    content: "♣";
    color: #000;
    font-size: 2.1em !important;
    display: block !important;
}

/* Full deck ace cards - ensure proper styling */
.full-deck .card.hearts-A .center-symbols,
.full-deck .card.diamonds-A .center-symbols,
.full-deck .card.clubs-A .center-symbols {
    position: relative;
}

.full-deck .card.hearts-A .center-symbols::before {
    content: "♥";
    color: #e74c3c;
    font-size: 2.1em !important;
    display: block !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.full-deck .card.diamonds-A .center-symbols::before {
    content: "♦";
    color: #e74c3c;
    font-size: 2.1em !important;
    display: block !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.full-deck .card.clubs-A .center-symbols::before {
    content: "♣";
    color: #000;
    font-size: 2.1em !important;
    display: block !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Face card styling for full deck - let base CSS handle this */

.deck-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 1;
}

.deck {
    position: relative;
    width: 120px; /* Increased to accommodate rotated cards */
    height: 160px; /* Increased to accommodate rotated cards */
    cursor: pointer;
    transition: transform 0.3s ease;
    border-radius: 8px;
    overflow: visible; /* Allow rotated cards to extend beyond container */
}

.deck:hover {
    transform: scale(1.05);
}

.card-back {
    width: 100%;
    height: 100%;
    background-image: var(--card-back-url, url('/assets/css_graphics/full_deck/cards/images/standard_deck/card_back.png'));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: none;
    border-radius: var(--card-border-radius);
    box-shadow: var(--card-shadow);
    position: relative;
}

/* Add a subtle stack effect to the deck */
.deck::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background-image: var(--card-back-url, url('/assets/css_graphics/full_deck/cards/images/standard_deck/card_back.png'));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 6px;
    opacity: 0.7;
    z-index: -1;
}

.deck::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    background-image: var(--card-back-url, url('/assets/css_graphics/full_deck/cards/images/standard_deck/card_back.png'));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 4px;
    opacity: 0.5;
    z-index: -2;
}

.deck-label {
    color: white;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.arrow {
    font-size: 2rem;
    color: white;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    z-index: 1;
}

.picked-cards {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 1;
}

.picked-cards-label {
    color: white;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.card-piles-container {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    flex-wrap: wrap;
}

.card-pile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-width: 150px;
    position: relative;
}

.pile-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    background: rgba(0, 0, 0, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 1.1rem;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.winning-pile .pile-label {
    background: rgba(0, 150, 0, 0.3);
    border-color: rgba(0, 255, 0, 0.3);
}

.losing-pile .pile-label {
    background: rgba(150, 0, 0, 0.3);
    border-color: rgba(255, 0, 0, 0.3);
}

.pile-container {
    position: relative;
    min-height: 270px;
    min-width: 225px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pile-tally {
    font-size: 2rem;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    background: rgba(0, 0, 0, 0.5);
    padding: 0.5rem 1rem;
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    min-width: 60px;
    text-align: center;
}

/* Override card styling for simulation */
.picked-cards .card {
    width: 135px;
    height: 189px;
    border: 1px solid #666; /* Hairline grey stroke */
    border-radius: 18px;
    background: #fff;
    position: absolute;
    box-shadow: none; /* No shadow by default */
    position: relative; /* For face image positioning */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 9px;
    font-family: 'Rockwell', 'Times New Roman', serif;
    font-weight: bold;
    font-size: 22px;
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 1;
}

/* Enhanced shadow for top 10 cards in each pile */
.pile-container .card:nth-child(-n+10) {
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Card falling animation */
@keyframes cardFall {
    0% {
        transform: translateY(-120px) scale(2) rotate(var(--initial-rotation, 0deg));
        opacity: 0;
    }
    50% {
        transform: translateY(-60px) scale(1.5) rotate(var(--initial-rotation, 0deg));
        opacity: 0.6;
    }
    100% {
        transform: translate(var(--final-x, 0px), var(--final-y, 0px)) scale(1) rotate(var(--final-rotation, 0deg));
        opacity: 1;
    }
}

/* Ensure the final state is maintained after animation */
@keyframes maintainFinalState {
    0% {
        transform: translate(var(--final-x, 0px), var(--final-y, 0px)) scale(1) rotate(var(--final-rotation, 0deg));
        opacity: 1;
    }
    100% {
        transform: translate(var(--final-x, 0px), var(--final-y, 0px)) scale(1) rotate(var(--final-rotation, 0deg));
        opacity: 1;
    }
}

.pile-container .card.falling {
    animation: cardFall 0.8s ease-out forwards !important;
    transition: none !important;
}

/* Ensure cards maintain their final state after animation completes */
.pile-container .card:not(.falling) {
    /* Use the maintainFinalState animation to keep the final position */
    animation: maintainFinalState 0.1s ease-out forwards !important;
    animation-fill-mode: forwards;
}

/* Pile card styling */
.pile-container .card {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: center;
    opacity: 1; /* Ensure cards are visible by default */
    border: 1px solid #666; /* Hairline grey stroke */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Very light drop shadow */
    /* Ensure the final state from animation is preserved */
    animation-fill-mode: forwards;
}


.pile-container .card:hover {
    transform: translateY(-2px) scale(1.02) !important;
    z-index: 1000;
    box-shadow: 
        0 1px 2px rgba(0,0,0,0.1);
}


.picked-cards .card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 
        0 8px 16px rgba(0,0,0,0.3),
        0 12px 24px rgba(0,0,0,0.2),
        0 16px 32px rgba(0,0,0,0.1);
    z-index: 1000;
}

.picked-cards .card.success {
    background: linear-gradient(135deg, #fff, #f8f9fa);
    animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

/* Corner styling for picked cards */
.picked-cards .corner-top {
    position: absolute;
    top: 12px;
    left: 12px;
    font-size: 22.8px;
    line-height: 1;
    font-family: 'Rockwell', 'Times New Roman', serif;
    font-weight: bold;
    text-shadow: 
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white,
        0 0 2px white;
    -webkit-text-stroke: 0.5px white;
}

.picked-cards .corner-bottom {
    position: absolute;
    bottom: 12px;
    right: 12px;
    font-size: 22.8px;
    line-height: 1;
    transform: rotate(180deg);
    font-family: 'Rockwell', 'Times New Roman', serif;
    font-weight: bold;
    text-shadow: 
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white,
        0 0 2px white;
    -webkit-text-stroke: 0.5px white;
}

/* Center symbols for picked cards */
.picked-cards .center-symbols {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    font-size: 36px;
    position: relative;
    z-index: 1; /* Lower than face image */
}

/* White stroke for center symbols */
.picked-cards .center-symbols::before,
.picked-cards .center-symbols::after {
    text-shadow: 
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white,
        0 0 2px white;
    -webkit-text-stroke: 0.5px white;
}

/* Face image styling */
/* Face image styling for picked cards (default - overridden by deck-specific rules) */
.picked-cards .face-image {
    width: 85% !important;
    height: 85% !important;
    object-fit: contain !important;
    border-radius: 4px !important;
    display: block !important;
    z-index: 1 !important;
    position: relative !important;
    margin: auto !important;
}


/* Upside-down card styling */
.picked-cards .card.upside-down,
.full-deck .card.upside-down {
    /* Ensure upside-down cards maintain proper display */
    transform-origin: center;
}


/* Face card styling - show suit symbols in corner values */
.picked-cards .card.hearts-J .corner-top .suit,
.picked-cards .card.hearts-J .corner-bottom .suit,
.picked-cards .card.hearts-Q .corner-top .suit,
.picked-cards .card.hearts-Q .corner-bottom .suit,
.picked-cards .card.hearts-K .corner-top .suit,
.picked-cards .card.hearts-K .corner-bottom .suit,
.picked-cards .card.diamonds-J .corner-top .suit,
.picked-cards .card.diamonds-J .corner-bottom .suit,
.picked-cards .card.diamonds-Q .corner-top .suit,
.picked-cards .card.diamonds-Q .corner-bottom .suit,
.picked-cards .card.diamonds-K .corner-top .suit,
.picked-cards .card.diamonds-K .corner-bottom .suit,
.picked-cards .card.clubs-J .corner-top .suit,
.picked-cards .card.clubs-J .corner-bottom .suit,
.picked-cards .card.clubs-Q .corner-top .suit,
.picked-cards .card.clubs-Q .corner-bottom .suit,
.picked-cards .card.clubs-K .corner-top .suit,
.picked-cards .card.clubs-K .corner-bottom .suit,
.picked-cards .card.spades-J .corner-top .suit,
.picked-cards .card.spades-J .corner-bottom .suit,
.picked-cards .card.spades-Q .corner-top .suit,
.picked-cards .card.spades-Q .corner-bottom .suit,
.picked-cards .card.spades-K .corner-top .suit,
.picked-cards .card.spades-K .corner-bottom .suit,
.full-deck .card.hearts-J .corner-top .suit,
.full-deck .card.hearts-J .corner-bottom .suit,
.full-deck .card.hearts-Q .corner-top .suit,
.full-deck .card.hearts-Q .corner-bottom .suit,
.full-deck .card.hearts-K .corner-top .suit,
.full-deck .card.hearts-K .corner-bottom .suit,
.full-deck .card.diamonds-J .corner-top .suit,
.full-deck .card.diamonds-J .corner-bottom .suit,
.full-deck .card.diamonds-Q .corner-top .suit,
.full-deck .card.diamonds-Q .corner-bottom .suit,
.full-deck .card.diamonds-K .corner-top .suit,
.full-deck .card.diamonds-K .corner-bottom .suit,
.full-deck .card.clubs-J .corner-top .suit,
.full-deck .card.clubs-J .corner-bottom .suit,
.full-deck .card.clubs-Q .corner-top .suit,
.full-deck .card.clubs-Q .corner-bottom .suit,
.full-deck .card.clubs-K .corner-top .suit,
.full-deck .card.clubs-K .corner-bottom .suit,
.full-deck .card.spades-J .corner-top .suit,
.full-deck .card.spades-J .corner-bottom .suit,
.full-deck .card.spades-Q .corner-top .suit,
.full-deck .card.spades-Q .corner-bottom .suit,
.full-deck .card.spades-K .corner-top .suit,
.full-deck .card.spades-K .corner-bottom .suit {
    display: inline !important;
}

/* Full deck corner styling with white stroke */
.full-deck .corner-top,
.full-deck .corner-bottom {
    text-shadow: 
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white,
        0 0 2px white;
    -webkit-text-stroke: 0.5px white;
}

/* Full deck center symbols with white stroke */
.full-deck .center-symbols::before,
.full-deck .center-symbols::after {
    text-shadow: 
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white,
        0 0 2px white;
    -webkit-text-stroke: 0.5px white;
}

/* Pip styling for picked cards - let base CSS handle this */

/* Winning criteria display */
.winning-criteria-display {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.criteria-label {
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    margin-bottom: 10px;
    text-align: center;
    font-size: 1.1rem;
}

.criteria-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.criteria-cards .card {
    width: 40px;
    height: 56px;
    border: 1px solid #666; /* Hairline grey stroke */
    border-radius: 6px;
    background: #fff;
    box-shadow: 
        1px 1px 3px rgba(0,0,0,0.2),
        2px 2px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2px;
    font-family: 'Rockwell', 'Times New Roman', serif;
    font-weight: bold;
    font-size: 8px;
    position: relative;
    transition: transform 0.2s ease;
}

.criteria-cards .card:hover {
    transform: scale(1.1);
    z-index: 10;
}

.criteria-cards .card.face-card {
    padding: 0;
}

.criteria-cards .card.face-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}

/* Suit styling for picked cards - let base CSS handle this */


/* Pip positioning for picked cards - let base CSS handle this */

/* Results section */
.results-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 2rem 0;
}

.probability-display {
    background: var(--light-gray);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--border);
}

.probability-display h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--primary);
}

.theoretical-probability,
.experimental-probability {
    margin-bottom: 1.5rem;
}

.theoretical-probability:last-child,
.experimental-probability:last-child {
    margin-bottom: 0;
}

.probability-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
    text-align: center;
    margin-bottom: 0.5rem;
}

.probability-fraction {
    font-size: 1rem;
    color: var(--gray);
    text-align: center;
}

.statistics {
    background: var(--light-gray);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--border);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 1.1rem;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-weight: bold;
    color: var(--dark);
}

.stat-value {
    color: var(--primary);
    font-weight: bold;
}

/* Progress section */
.progress-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--light-gray);
    border-radius: 12px;
    border: 2px solid var(--border);
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-weight: bold;
    color: var(--dark);
}

/* Explanation section */
.explanation-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.explanation-section h3 {
    margin-top: 0;
    color: var(--primary);
}

.explanation-content {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--dark);
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .controls {
        grid-template-columns: 1fr;
    }
    
    .results-section {
        grid-template-columns: 1fr;
    }
    
    .deck-display {
        flex-direction: column;
        gap: 1rem;
    }
    
    .arrow {
        transform: rotate(90deg);
    }
    
    .deck {
        width: 100px; /* Slightly smaller on mobile */
        height: 140px;
    }
    
    .picked-cards-container {
        max-width: 300px;
    }
    
    .card {
        width: 50px;
        height: 70px;
        font-size: 0.8em;
        border: 1px solid #666; /* Hairline grey stroke */
    }
    
    .card-suit {
        font-size: 14px;
    }
    
    .card-value {
        font-size: 12px;
    }
    
    .card-center {
        font-size: 16px;
    }
}

/* Animation for card picking */
@keyframes cardPick {
    0% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

@keyframes cardRemove {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.8) rotate(-10deg) translateY(-20px);
    }
}

@keyframes deckLow {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7);
    }
    100% {
        box-shadow: 0 0 0 10px rgba(255, 0, 0, 0);
    }
}

.card.picked {
    animation: cardPick 0.5s ease-in-out;
}

.card.removing {
    animation: cardRemove 0.3s ease-in forwards;
}

/* Success highlighting */
.card.success {
    background: linear-gradient(135deg, #fff, #f8f9fa);
}

/* Disabled state */
.deck.disabled {
    cursor: not-allowed;
}

/* Input help text */
.input-help {
    display: block;
    font-size: 0.9em;
    color: #666;
    margin-top: 0.25rem;
    font-style: italic;
}

/* Tally Chart Section */
.tally-chart-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    border: 1px solid #dee2e6;
}

.tally-chart-section h3 {
    margin: 0 0 1rem 0;
    color: var(--primary);
    text-align: center;
    font-size: 1.2rem;
}

.tally-chart-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: white;
    padding: 1rem;
}

.tally-chart-message {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

.tally-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.tally-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: #f8f9fa;
    transition: background-color 0.2s ease;
}

.tally-item:hover {
    background: #e9ecef;
}

.tally-card-name {
    font-weight: 500;
    color: #333;
    font-size: 0.9rem;
}

.tally-count {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.8rem;
    min-width: 2rem;
    text-align: center;
}

.tally-count.zero {
    background: #6c757d;
}

.tally-stats {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.tally-stats h4 {
    margin: 0 0 0.5rem 0;
    color: var(--primary);
    font-size: 1rem;
}

.tally-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
}

.tally-stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid #e9ecef;
}

.tally-stat-label {
    font-weight: 500;
    color: #666;
}

.tally-stat-value {
    font-weight: bold;
    color: var(--primary);
}

.deck.disabled:hover {
    transform: none;
}

/* CRITICAL: Card backs with card_back.png image - 95% background size with white border (highest priority) */
.deck-display .deck .card-back {
    background-size: 95% !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border: 4px solid white !important;
    box-shadow: 
        0 0 0 1px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.15) !important;
}

/* Apply white border to deck pile cards as well */
.deck-display .deck .deck-card {
    border: 4px solid white !important;
    box-shadow: 
        0 0 0 1px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.15) !important;
}
