@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap');

body {
    position: relative;
    /* Needed for absolute positioning of the back button */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100vh;
    margin: 0;
    padding-top: 2rem;
    font-family: 'Poppins', sans-serif;
    color: #fafafa;
}

#go-back-button {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    text-decoration: none;
    transition: transform 0.2s, filter 0.2s;
    z-index: 10;
    /* Ensure it's on top of other content */
}

#go-back-button:hover {
    
    filter: brightness(1.1);
}

#go-back-button img {
    width: 33px;
    height: 33px;
    object-fit: contain;
    /* Ensures the image scales nicely */
}

h1 {
    margin: 0;
    /* Remove default margins */
    color: #4ade80;
    font-weight: 600;
    font-size: 3rem;
    letter-spacing: 2px;
    text-shadow: 0 0 15px rgba(74, 222, 128, 0.4);
}


#game-container {
    position: relative;
    width: 90vw;
    max-width: 600px;
    aspect-ratio: 1 / 1; /* This ensures the container is always a square */
    /* Set a max-width for larger screens */
    border: 2px solid #3a3a3a;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
    /* Ensures canvas corners are rounded */
}

#game-canvas {
    background-color: #1e1e1e;
    width: 100%;
    height: 100%;
    display: block;
    /* Removes extra space below canvas */
}

@media (max-width: 600px) {
    h1 {
        font-size: 2rem;
    }

    #stats-container>div {
        font-size: 0.9rem;
        padding: 6px 12px;
    }
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 26, 26, 0.85);
    backdrop-filter: blur(5px);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 2.5rem;
    font-weight: 600;
    visibility: hidden;
}

#overlay.visible {
    visibility: visible;
}

#overlay button {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 10px 20px;
    margin-top: 20px;
    border: none;
    border-radius: 8px;
    background-color: #4ade80;
    color: #1a1a1a;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
}

#overlay button:hover,
#overlay button:focus {
    transform: scale(1.05);
    filter: brightness(1.1);
    outline: none;
}

#mobile-controls {
    display: none;
    /* Hidden by default on larger screens */
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 20px;
    user-select: none;
    /* Prevent text selection on rapid taps */
}

/* This class will be added by JavaScript to show the controls */
#mobile-controls.visible {
    display: flex;
}

#mobile-controls button {
    background-color: #3a3a3a;
    border: none;
    color: #fafafa;
    font-size: 1.5rem;
    line-height: 1;
    width: 50px;
    height: 50px;
    border-radius: 15px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    /* Remove tap highlight on mobile */
    transition: background-color 0.2s;
}

#mobile-controls button:active {
    background-color: #5a5a5a;
}

#middle-row {
    display: flex;
    gap: 40px;
    /* Space between left and right buttons */
    margin: 8px 0;
}

/* --- Orientation Lock Fix --- */
#orientation-warning {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #1a1a1a;
    color: #fafafa;
    z-index: 9999;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 1.2rem;
}

/* When body has this class, show the warning and hide everything else */
body.landscape-mode-active #orientation-warning {
    display: flex;
}

body.landscape-mode-active > *:not(#orientation-warning) {
    display: none !important;
}
