@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');

:root {
    /* Beautiful Light Theme Colors */
    --bg-color: #f0f4f8;
    --container-bg: #ffffff;
    --text-color: #1e293b;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --success-color: #10b981;
    --success-hover: #059669;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --card-hover-shadow: 0 15px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -5px rgba(0, 0, 0, 0.1);
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    /* Removed overflow: hidden so it can scroll if content is too large */
    min-height: 100%;
    background-color: var(--bg-color);
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Changed from center to flex-start to allow natural scrolling from top */
}

#app {
    width: 100%;
    min-height: 100vh; /* Changed from fixed height */
    max-width: 1200px; /* Made the container wider for larger cards */
    background-color: var(--container-bg);
    padding: 3vh 3vw;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

@media (min-width: 600px) {
    #app {
        min-height: 94vh;
        margin: 3vh 0; /* Adding margin for breathing room top/bottom when scrolling */
        border-radius: 24px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.06);
        padding: 4vh 4vw;
    }
}

h1 {
    margin: 0 0 2vh 0;
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 700;
    background: linear-gradient(to right, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    flex-shrink: 0;
}

#message-area {
    font-size: clamp(1.1rem, 3vh, 1.5rem);
    margin-bottom: 3vh;
    min-height: 60px;
    color: #475569;
    font-weight: 600;
    white-space: pre-line;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Changed to start so large elements don't get vertically centered weirdly */
    position: relative;
    width: 100%;
    padding-bottom: 2vh;
}

/* Base Card Styling - Greatly Increased Size */
.card {
    height: clamp(120px, 20vh, 220px); /* Much larger base height */
    width: auto;
    aspect-ratio: 2/3;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
    display: block;
    background-color: white;
}

.grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    gap: 2vh 2vw; /* Increased gap */
    width: 100%;
}

.grid .card:hover {
    transform: translateY(-1.5vh) scale(1.05);
    box-shadow: var(--card-hover-shadow);
    z-index: 10;
}

/* Column Dealing Display */
.column-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex: 1;
    max-width: 33vw; /* Slightly wider max-width for bigger cards */
}

.column {
    position: relative;
    width: 100%;
    /*
       Recalculated explicit height for much larger cards + overlapping.
       Using pixels for offset now to ensure it scales cleanly with the larger cards.
    */
    height: calc((6 * 60px) + clamp(120px, 20vh, 220px));
    display: flex;
    justify-content: center;
    margin-bottom: 40px; /* Force significant space between bottom card and button */
}

.column .card {
    position: absolute;
    margin: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.column .card:hover {
    transform: translateX(20px) translateY(-10px);
    box-shadow: var(--card-hover-shadow);
}

.column-wrapper button {
    margin-top: auto;
    width: 80%; /* Ensure button stays a reasonable size compared to the massive columns */
    max-width: 250px;
}

/* Group display */
.group-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3vw;
    flex-wrap: wrap;
    width: 100%;
}

.card-group {
    display: flex;
    padding: 2vh;
    border: 2px solid rgba(0,0,0,0.05);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: rgba(0,0,0,0.015);
    position: relative;
    margin-bottom: 2vh; /* Give groups some breathing room if they wrap */
}

.card-group:hover {
    border-color: #93c5fd;
    background-color: rgba(147, 197, 253, 0.15);
    transform: translateY(-1vh);
}

.card-group.selected {
    border-color: var(--success-color);
    background-color: rgba(16, 185, 129, 0.1);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.card-group .card {
    /* Larger negative margin because cards are huge */
    margin-left: -60px;
    box-shadow: -4px 0 12px rgba(0,0,0,0.15);
}

.card-group .card:first-child {
    margin-left: 0;
    box-shadow: var(--card-shadow);
}

/* Buttons */
#controls {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2vh 0;
    margin-top: 2vh;
}

button {
    padding: 15px 40px;
    font-size: clamp(1rem, 2vh, 1.2rem);
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 6px 15px rgba(59, 130, 246, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

button:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

button:active:not(:disabled) {
    transform: translateY(1px);
}

button:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

/* Specific styling for smaller mobile screens */
@media (max-width: 600px) {
    .card-group .card {
        margin-left: -50px;
    }
    .grid {
        gap: 1.5vh 2vw;
    }

    /* Slightly smaller card on mobile to fit the 3x7 grid but still huge */
    .card {
        height: clamp(100px, 15vh, 140px);
    }

    .column {
        /* Recalculate column height for mobile using mobile overlapping size (50px) */
        height: calc((6 * 50px) + clamp(100px, 15vh, 140px));
    }

    .column-wrapper button {
        width: 95%;
        padding: 12px 10px;
        font-size: 0.9rem;
    }
}