/* ==============================
   Global Styles
   ============================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    background-color: #1a472a; /* Solid green background */
    color: #ffffff;
}

h1, h2, h3, .font-press-start {
    font-family: 'Press Start 2P', cursive;
}

/* Prevent touch-based scrolling and pinch-zoom on the game canvas */
#gameCanvas {
    touch-action: none;
    background: #1a472a;
    border-radius: 10px;
    border: 2px solid #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

/* ==============================
   Card Styling with Animations
   ============================== */
.card {
    width: 60px;
    height: 90px;
    background-color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    box-shadow: 
        0 0 5px rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    user-select: none;
    transform-origin: center bottom;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.dragging {
    transform: scale(1.05);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

/* ==============================
   Deal Animation 
   ============================== */
@keyframes dealCard {
    0% {
        transform: translateY(-100px) scale(0.8);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.deal-animation {
    animation: dealCard 0.3s ease-out forwards;
}

/* ==============================
   Move Animation 
   ============================== */
@keyframes moveCard {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
    100% {
        transform: translateY(0);
    }
}

.move-animation {
    animation: moveCard 0.5s ease-out;
}

/* ==============================
   Stock Deal Animation 
   ============================== */
@keyframes stockDeal {
    0% {
        transform: translateX(50px) rotate(10deg);
        opacity: 0;
    }
    100% {
        transform: translateX(0) rotate(0);
        opacity: 1;
    }
}

.stock-deal {
    animation: stockDeal 0.4s ease-out forwards;
}

/* ==============================
   Complete Sequence Animation 
   ============================== */
@keyframes completeSequence {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.complete-sequence {
    animation: completeSequence 0.8s ease-in forwards;
}

/* ==============================
   Hint Animation 
   ============================== */
@keyframes hintPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(255, 255, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 0, 0);
    }
}

.hint-highlight {
    animation: hintPulse 1.5s infinite;
}

/* ==============================
   Button Styles
   ============================== */
button {
    background-color: #2c7744;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 15px;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #1e5631;
}

button:active {
    transform: scale(0.98);
}

/* ==============================
   Pop-up Message Styles
   ============================== */
.popup {
    background-color: #ffffff;
    color: #000000;
    border: 1px solid #ccc;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

.popup-button {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.popup-button:hover {
    background-color: #45a049;
}

/* Hidden Class to Hide Elements */
.hidden {
    display: none;
}

/* ==============================
   Responsive Adjustments
   ============================== */
@media (max-width: 768px) {
    #controlButtons {
        position: static;
        margin-top: 20px;
        flex-wrap: wrap;
        justify-content: center;
    }

    #controlButtons button {
        font-size: 14px;
        padding: 8px 12px;
        margin: 4px;
    }
    
    .game-stats div {
        font-size: 16px !important;
    }
}

/* ==============================
   Game Stats Styling
   ============================== */
#gameStats {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

#timerDisplay,
#movesDisplay,
#scoreDisplay,
#stockDisplay {
    font-family: 'Roboto', sans-serif !important;
    font-size: 18px !important;
    color: white !important;
    font-weight: bold !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* ==============================
   Overlay Styles
   ============================== */
#startGameOverlay,
#rulesOverlay,
#statsOverlay {
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
}

/* ==============================
   Dropdown menu
   ============================== */
.dropdown-menu {
    display: none;
    min-width: 180px;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown button svg {
    transition: transform 0.2s ease-in-out;
}

.dropdown:hover button svg {
    transform: rotate(180deg);
}

.dropdown-menu a.active {
    background-color: #f3f4f6;
}

.dropdown {
    position: relative;
    z-index: 50;
}

/* ==============================
   Content Section
   ============================== */
.content-section {
    background-color: #2c7744;
    padding: 2rem;
    margin: 3rem auto; /* Changed from '3rem 0' to '3rem auto' for centering */
    border-radius: 8px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    text-align: center; /* Add center alignment as default */
    max-width: 1100px; /* Control maximum width */
    width: 95%; /* Use percentage width for responsiveness */
}

.content-section h2,
.content-section h3 {
    font-family: 'Press Start 2P', cursive;
    color: #fff;
    margin-bottom: 1.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    text-align: center; /* Ensure headings are centered */
}

.content-section h2 {
    font-size: 1.8rem;
}

.content-section h3 {
    font-size: 1.2rem;
    margin-top: 2rem;
}

.content-section p {
    font-family: 'Roboto', sans-serif;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    color: #fff;
    max-width: 800px; /* Limit paragraph width for readability */
    margin-left: auto;
    margin-right: auto;
}

.content-section ul {
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 1.5rem;
    list-style-position: inside; /* Keep bullets inside for better alignment */
    max-width: 800px; /* Control list width */
}

.content-section li {
    margin-bottom: 0.8rem;
    line-height: 1.6;
    text-align: left; /* Keep list items left-aligned for readability */
}

.content-section strong {
    font-weight: 700;
    color: #ffcc00;
}

/* Ensure the game cards grid is centered properly */
.content-section .grid {
    margin-left: auto;
    margin-right: auto;
    justify-content: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .content-section {
        padding: 1.5rem;
    }
    
    .content-section h2 {
        font-size: 1.5rem;
    }
    
    .content-section h3 {
        font-size: 1rem;
    }
}

/* ==============================
   Game Card Grid
   ============================== */
.game-card {
    background-color: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.play-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #2c7744;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: 700;
    transition: background-color 0.3s;
}

.play-button:hover {
    background-color: #1e5631;
}

/* ==============================
   Stock Counter
   ============================== */
#stockDisplay {
    position: relative;
    transition: all 0.3s ease;
}

#stockDisplay.empty {
    color: #ff6b6b !important;
}

#stockDisplay.flash {
    animation: flash 1s;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}