body {
    margin: 0;
    padding: 0;
    background-color: #222;
    display: flex;
    flex-direction: column;
    /* Stack vertically */
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    color: white;
    font-family: 'Courier New', Courier, monospace;
    touch-action: none;
}

#game-container {
    position: relative;

    /* Calculate max dimensions to fit in remainig space (above controls) */
    /* Controls are approx 100px or 20vh. Let's assume 80vh available for game */

    /* 2. Constrain height to available space (flex) */
    flex: 1;
    /* Take remaining space */
    width: 100%;
    /* Keep centering */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;

    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    background: #000;
    margin-bottom: 0;
    flex-shrink: 0;
}

canvas {
    display: block;
    /* Maintain Aspect Ratio */
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 16/9;
    object-fit: contain;
}

/* Mobile Controls Area - Below Game */
#mobile-controls {
    display: none;
    width: 100%;
    /* Minimize height: Content only */
    height: auto;
    min-height: 0;

    background: #333;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2px 0;
    /* Minimal padding */
    box-sizing: border-box;
    border-top: 2px solid #555;
    z-index: 10;
    flex-shrink: 0;
}

/* Title Screen Controls (Mobile) */
#title-controls {
    display: none;
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #555;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 20;
}

.cpu-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 18px;
    color: white;
}

.cpu-btn {
    background: #444;
    color: white;
    border: 1px solid #666;
    width: 40px;
    height: 40px;
    font-size: 20px;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
}

.cpu-btn:active {
    background: #666;
}

#move-controls,
#action-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

/* Container for main controls row */
div:has(> #move-controls) {
    /* This selector might be tricky without a wrapper class. Let's just wrap them in HTML if needed, or rely on flex-direction: row for a wrapper */
}

/* Actually, let's wrap Move and Action in a row */
.controls-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    margin-bottom: 5px;
}

.shop-btn {
    width: 50px;
    height: 40px;
    background: #555;
    color: white;
    border: 1px solid #777;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    margin: 2px;
}

.shop-btn:active {
    background: #777;
}

#touch-area-hint {
    display: block !important;
    /* Force show in mobile-controls */
    position: static;
    /* Reset absolute */
    transform: none;
    margin-bottom: 5px;
}

/* Show controls on small screens (mobile) */
@media (max-width: 1000px),
(hover: none) {
    #mobile-controls {
        display: flex;
    }
}

/* End of styles */

/* PWA Install Banner */
#pwa-install-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: #222;
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    padding: 10px;
    display: none;
    /* Hidden by default */
    z-index: 1000;
    align-items: center;
    justify-content: space-between;
}

#pwa-install-banner.visible {
    display: flex;
}

.pwa-content {
    display: flex;
    align-items: center;
    width: 100%;
}

.pwa-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    margin-right: 10px;
}

.pwa-text {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.pwa-title {
    font-weight: bold;
    font-size: 14px;
}

.pwa-desc {
    font-size: 12px;
    color: #ccc;
}

#pwa-install-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 10px;
}

#pwa-close-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    margin-left: 10px;
}