#game-title {
    text-align: center;
    font-size: clamp(28px, 5vw, 42px);
    font-weight: normal;
    color: #d1d1d1; 
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin-top: 7px;
    padding: 10px;
    border-bottom: 1px solid #25923f;
    background-color: #1e3d23; 
}

/* Ensure settings are in two rows */
.settings-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
}

/* Each setting (label + select/input) as a box */
.settings-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: calc(50% - 10px); /* Two columns */
    min-width: 120px;
}

#menu #game-settings {
    display: flex;
    flex-wrap: wrap; 
    align-items: flex-end; /* need? center instead? */
    gap: 15px 20px;
    padding: 10px; 
    background-color: #2e4d33; /* Darker green background */
    border: 1px solid #3a5d40; /* Darker green border */
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.settings-item {
    display: flex;
    flex-direction: column; /* Stack label on top of select */
    flex-grow: 1; /* Allow items to grow to fill space */
    flex-basis: 150px; /* Suggest a minimum base width before wrapping */
    min-width: 120px; /* Absolute minimum width */
}


#menu #game-settings label {
    margin-right: 2px; /* Reduced space between label and option */
    margin-bottom: 5px; 
    font-weight: normal; /* Normal font-weight */
    color: #d1d1d1; /* Lighter text */
    font-size: clamp(12px, 2vw, 14px);
}

#menu #game-settings select,
#menu #game-settings input[type="color"],
#menu #game-settings button {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 5px 8px; /* Reduced padding */
    border: 1px solid #4a6d50; /* Darker green border */
    border-radius: 4px;
    background-color: #3e5d43; /* Darker green background */
    color: #d1d1d1; /* Lighter text */
    font-size: clamp(14px, 2.2vw, 16px);
}

#menu #game-settings input[type="color"] {
    padding: 5px; 
    width: 60px;
}

#menu #game-settings button {
    background-color: #25923f;
    color: #d1d1d1;
    cursor: pointer;
    border: none;
    font-weight: bold;
}

#menu #game-settings button:hover {
    background-color: #1f7a33;
}


#menu #game-settings button {
    background-color: #25923f; /* Theme matching button */
    color: #d1d1d1;
    cursor: pointer;
    border: none;
}

#menu #game-settings button:hover {
    background-color: #1f7a33; /* Darker hover effect */
}

/* Game board container */
#game-board {
    display: grid;
    gap: 4px;
    width: fit-content;
    max-width: 90vw;
    margin: 30px auto;
    margin-bottom: 5px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease;
    border-radius: 5px;
}

/* Card styling */
.card {
    width: 100px;
    height: 100px;
    background-color: #87cba1;
    border: 2px solid #0b271b;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    perspective: 200px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s, color 0.3s;
}

.card.auto-contrast {
    color: white; 
}

/* 3D Flip effect */
.card-inner {
    position: relative;
    width: 90%;
    height: 90%;
    transition: transform 0.3s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card-front {
    background-color: #298844;
    transform: rotateY(0deg);
    text-align: center; 
    white-space: normal; 
    line-height: 1.2;
    padding: 0px;
}

.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #3fb661;
    transform: rotateY(180deg);
    text-align: center; 
    white-space: normal; 
    line-height: 1.2; 
    padding: 0px; 
}

.card.matched .card-inner {
    transform: rotateY(180deg);
}

#score-area , #timer-area{
    text-align: center;
    margin-top: 1px;
    font-size: 25px;
    font-family: Arial, Helvetica, sans-serif;
    color: #0b271b;
    margin-top: 1px;
}

#score-timer-bar {
    display: flex;
    justify-content: space-around;  /* less extreme spacing than space-between */
    align-items: center;
    margin: 5px auto;  /* less space around it */
    width: 90%;        /* narrower container brings them closer together */
    max-width: 500px;  /* reduce from 600px */
    font-size: 25px;
    font-family: Arial, Helvetica, sans-serif;
    color: #6a1717;
}

#game-title {
    text-align: center;
    font-size: clamp(28px, 5vw, 42px);
    font-weight: normal;
    color: #d1d1d1; 
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin-top: 7px;
    padding: 10px;
    border-bottom: 1px solid #25923f;
    background-color: #1e3d23; 
}

/* Ensure settings are in two rows */
.settings-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
}

/* Each setting (label + select/input) as a box */
.settings-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: calc(50% - 10px); /* Two columns */
    min-width: 120px;
}

#menu #game-settings {
    display: flex;
    flex-wrap: wrap; 
    align-items: flex-end; /* need? center instead? */
    gap: 15px 20px;
    padding: 10px; 
    background-color: #2e4d33; /* Darker green background */
    border: 1px solid #3a5d40; /* Darker green border */
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.settings-item {
    display: flex;
    flex-direction: column; /* Stack label on top of select */
    flex-grow: 1; /* Allow items to grow to fill space */
    flex-basis: 150px; /* Suggest a minimum base width before wrapping */
    min-width: 120px; /* Absolute minimum width */
}

#menu #game-settings label {
    margin-right: 2px; /* Reduced space between label and option */
    margin-bottom: 5px; 
    font-weight: normal; /* Normal font-weight */
    color: #d1d1d1; /* Lighter text */
    font-size: clamp(12px, 2vw, 14px);
}

#menu #game-settings select,
#menu #game-settings input[type="color"],
#menu #game-settings button {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 5px 8px; /* Reduced padding */
    border: 1px solid #4a6d50; /* Darker green border */
    border-radius: 4px;
    background-color: #3e5d43; /* Darker green background */
    color: #d1d1d1; /* Lighter text */
    font-size: clamp(14px, 2.2vw, 16px);
}

#menu #game-settings input[type="color"] {
    padding: 5px; 
    width: 60px;
}

#menu #game-settings button {
    background-color: #25923f;
    color: #d1d1d1;
    cursor: pointer;
    border: none;
    font-weight: bold;
}

#menu #game-settings button:hover {
    background-color: #1f7a33;
}


#menu #game-settings button {
    background-color: #25923f; /* Theme matching button */
    color: #d1d1d1;
    cursor: pointer;
    border: none;
}

#menu #game-settings button:hover {
    background-color: #1f7a33; /* Darker hover effect */
}

/* Game board container */
#game-board {
    display: grid;
    gap: 8px;
    width: fit-content;
    max-width: 90vw;
    margin: 30px auto;
    margin-bottom: 5px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease;
    border-radius: 5px;
    overflow-x: auto; /* Allow horizontal scrolling if needed */
    overflow-y: visible;
}

/* Card styling */
.card {
    width: 100px;
    height: 100px;
    background-color: #87cba1;
    border: 2px solid #0b271b;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    perspective: 600px;          /* ← increased → more natural 3D feel */
    box-shadow: 2px 2px 8px rgba(0,0,0,0.25);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

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

/* Flutter on click / attention state */
@keyframes cardFlutter {
    0%   { transform: rotateY(0deg)   rotateX(0deg)   translateZ(0)      scale(1); }
    20%  { transform: rotateY(15deg)  rotateX(9deg)   translateZ(15px)   scale(1.05); }
    40%  { transform: rotateY(-12deg) rotateX(-6deg)  translateZ(20px)   scale(1.08); }
    60%  { transform: rotateY(8deg)   rotateX(4deg)   translateZ(24px)   scale(1.05); }
    80%  { transform: rotateY(-4deg)  rotateX(-2deg)  translateZ(10px)   scale(1.02); }
    100% { transform: rotateY(0deg)   rotateX(0deg)   translateZ(0)      scale(1); }
}

.card.flutter .card-inner {
    animation: cardFlutter 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);  /* ← overshoot + settle */
    transform-style: preserve-3d;
}
.card.auto-contrast {
    color: white; 
}

.card-inner {
    position: relative;
    width: 95%;
    height: 95%;
    display: flex;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.25);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card-front {
    background-color: #298844;
    transform: rotateY(0deg);
    text-align: center; 
    white-space: normal; 
    line-height: 1.2;
    padding: 0px;
}

.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #3fb661;
    transform: rotateY(180deg);
    text-align: center; 
    white-space: normal; 
    line-height: 1.2; 
    padding: 0px; 
}

.card.matched .card-inner {
    transform: rotateY(180deg);
}

#score-area , #timer-area{
    text-align: center;
    margin-top: 1px;
    font-size: 25px;
    font-family: Arial, Helvetica, sans-serif;
    color: #0b271b;
    margin-top: 1px;
}

#score-timer-bar {
    display: flex;
    justify-content: space-around;  /* less extreme spacing than space-between */
    align-items: center;
    margin: 5px auto;  /* less space around it */
    width: 90%;        /* narrower container brings them closer together */
    max-width: 500px;  /* reduce from 600px */
    font-size: 25px;
    font-family: Arial, Helvetica, sans-serif;
    color: #6a1717;
}



/* Responsive adjustments */
@media (max-width: 700px), (orientation: portrait) {
    #menu #game-settings {
        flex-direction: column; 
        align-items: stretch; 
    }

    .settings-item {
        width: 100%; 
        flex-basis: auto; 
    }
    
    /* Mobile card adjustments */
    #game-board {
        gap: 4px;
        max-width: 100vw; /* Allow full width */
        padding: 1px;
        margin: 1px 0; /* Remove auto centering */
        width: 100%; /* Full width container */
        overflow-x: auto; /* Enable horizontal scrolling */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    .card {
        /* Fixed smaller size for mobile - grid will scroll if too many columns */
        width: 70px;
        height: 70px;
        font-size: 16px;
        min-width: 60px;
        min-height: 60px;
    }
    
    .card-front, .card-back {
        font-size: clamp(12px, 3vw, 16px);
    }
    
    /* Adjust score/timer bar for mobile */
    #score-timer-bar {
        font-size: clamp(18px, 4vw, 22px);
        width: 95%;
    }
}