html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    font-family: 'Gill Sans', serif;
    text-align: center;
}

.container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.landing-bg, .farm-selection-bg, .game-screen-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.title-bg, .farm-bg, .game-screen-bg {
    pointer-events: all !important;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.title-bg {
    cursor: pointer;
}

.back-btn {
    width: 220px;
    padding: 1rem;
    font-size: 1.4rem;
    border-radius: 25px;
    background-color: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    border: 2px solid #2c3e50;
    cursor: pointer;
    transition: all 0.3s ease;
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.back-btn:hover {
    transform: translateX(-50%) scale(1.05);
    background-color: #2c3e50;
    color: white;
}

.farm-grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin: 2rem auto;
    max-width: 800px;
    padding: 2rem;
    margin-top: 40vh;
}

.farm-grid button {
    padding: 2rem;
    font-size: 1.3rem;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    border: 2px solid #2c3e50;
    cursor: pointer;
    transition: all 0.3s ease;
}

.farm-grid button:hover {
    transform: scale(1.05);
    background-color: #2c3e50;
    color: white;
}

.back-btn {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: white;
    padding: 20px;
    width: 80%;
    height: 80%;
    background: rgba(255, 208, 69, 0.9);
    border-radius: 10px;
    text-align: left;
    position: relative;
}

.instructions-svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: auto;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    color: #333;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    border-radius: 50%;
    border: 1px solid #ddd;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

.open-btn {
    padding: 1rem 2rem;
    font-size: 2em;
    cursor: pointer;
    color: black;
    border: none;
    border-radius: 5px;
}

li a {
    text-decoration: none;
    color: #fff;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

button {
    margin: 1em;
    padding: 15px 30px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 0;
    border: none;
    background-color: brown;
    color: white;
}

.game-container {
    display: grid;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

.card {
    width: 100px;
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    background: transparent;
    perspective: 1000px;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
}

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

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: transparent;
    border-radius: 10px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border-radius: 5px;
    overflow: hidden;
}

.card-front {
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    padding: 0;
    margin: 0;
    display: block;
    border-radius: 10px;
}

.card-back {
    background: transparent;
    color: #333;
    transform: rotateY(180deg);
    border: 1px solid #ddd;
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    padding: 0;
    margin: 0;
    display: block;
}

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

section {
    text-align: center;
    align-items: center;
    justify-content: center;
}

.win-popup-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.win-popup {
    background: linear-gradient(to bottom, #fcea8e, #24bcb4);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 500px;
    width: 90%;
    position: relative;
    border: 3px solid #1b3665;
    font-family: 'Gill Sans', serif;
}

.win-popup h2 {
    color: #1b3665;
    font-size: 2rem;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
}

.win-popup p {
    color: #1b3665;
    font-size: 1.2rem;
    margin-bottom: 15px;
    font-weight: bold;
}

.win-popup button {
    background-color: #74b843;
    color: white;
    border: none;
    padding: 12px 25px;
    margin: 10px;
    font-size: 1.1rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.win-popup button:hover {
    background-color: #1b3665;
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.win-popup .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background-color: #1b3665;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.win-popup .close-btn:hover {
    background-color: #e74c3c;
    transform: scale(1.1);
}

#finalWinPopup {
    background: linear-gradient(to bottom, #fcea8e, #74b843);
}

#finalWinPopup h2 {
    color: #1b3665;
}

.final-reward-svg {
    width: 250px;
    height: 250px;
    margin: 20px auto;
    display: block;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 15px;
    border: 3px solid #1b3665;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#finalWinPopup button {
    background-color: #1b3665;
    color: white;
}

#finalWinPopup button:hover {
    background-color: #24bcb4;
}

.timer-box {
    background-color: rgb(0, 0, 0);
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.2em;
    margin: 1rem auto;
}

.basket-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.basket {
    width: 80px;
    height: 80px;
    background-color: #078d00;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.2em;
    border-radius: 5px;
    position: relative;
}

.basket img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}

.reward-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.reward-placeholder {
    width: 80px;
    height: 80px;
    background-color: #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    color: black;
    font-size: 1em;
    border-radius: 5px;
}

.basket-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.basket {
    width: 80px;
    height: 80px;
    background-color: #078d00;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.2em;
    border-radius: 5px;
}

.win-popup-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.win-popup {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    text-align: center;
}

/* Navigation buttons in Farm Selection page */
.navigation-buttons {
    position: absolute;
    bottom: 2rem;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 2rem;
    z-index: 10;
}

.back-btn, .home-btn {
    width: 150px;
    padding: 0.8rem;
    font-size: 1.2rem;
    border-radius: 25px;
    background-color: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    border: 2px solid #2c3e50;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover, .home-btn:hover {
    transform: scale(1.05);
    background-color: #2c3e50;
    color: white;
}

/* Game Board Container */
#gameBoardContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#gameScreenSvg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: all;
}

#gameBoard {
    position: relative;
    z-index: 5;
}

#gameBoardContainer h1,
#gameBoardContainer .timer-box,
#gameBoardContainer .basket-container,
#gameBoardContainer .reward-container,
#gameBoardContainer #gameBackButton {
    position: relative;
    z-index: 5;
}

#gameBackButton {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
}

/* Hide the HTML buttons when SVG elements are properly loaded and functional */
.farm-selection-bg #backButton.hidden,
.farm-selection-bg #homeButton.hidden,
.game-screen-bg #gameBackButton.hidden {
    display: none;
}

.farm-bg {
    pointer-events: all !important;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Style for fallback level buttons */
.fallback-level-buttons {
    position: absolute;
    z-index: 10;
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
    top: 50%;
    transform: translateY(-50%);
    padding: 20px;
}

.fallback-level-button {
    padding: 15px 30px;
    font-size: 18px;
    background-color: #ff9500;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.fallback-level-button:hover {
    background-color: #e67e00;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.fallback-level-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Ensure SVG objects are properly interactive */
object.farm-bg {
    pointer-events: all !important;
}

.game-page {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}

@media only screen and (min-width: 320px) and (max-width: 1280px) and (orientation: landscape) {
    body {
        background-color: #ffffff;
    }
}

.win-popup button:hover {
    background-color: #28a745;
    transform: scale(1.05);
}

/* Coming Soon Popup Styling */
.coming-soon-content {
    display: flex;
    background-color: #003061;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    padding: 20px;
}

.coming-soon-content h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #ffffff;
    font-weight: bold;
}

.coming-soon-content p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: #555;
}

.lock-icon {
    font-size: 5rem;
    margin: 20px 0;
    animation: pulse 1.5s infinite;
    color: #e74c3c;
}

.popup-button {
    padding: 10px 25px;
    font-size: 1.2rem;
    background-color: #1aa531;
    color: rgb(0, 0, 0);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.popup-button:hover {
    background-color: #0cae0cb0;
    transform: scale(1.05);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Farm overlays for clickable areas */
.farm-overlays {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.farm-overlay {
    position: absolute;
    cursor: pointer;
    background-color: transparent;
    pointer-events: auto;
}

.winter-farm-overlay {
    bottom: 10%;
    left: 5%;
    width: 35%;
    height: 30%;
}

.spring-farm-overlay {
    top: 10%;
    left: 5%;
    width: 35%;
    height: 30%;
}

.fall-farm-overlay {
    bottom: 10%;
    right: 5%;
    width: 35%;
    height: 30%;
}

/* Improve visibility and styling of back buttons */
.back-button {
    position: absolute;
    bottom: 20px;
    left: 49%;
    transform: translateX(-50%);
    padding: 12px 24px;
    font-size: 1.2rem;
    background-color: #10b341;
    color: rgb(0, 0, 0);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.back-button:hover {
    background-color: #29b97fc6;
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* Ensure game pages have proper positioning for elements */
.game-page {
    position: relative;
    width: 100%;
    height: 100%;
}