/* Inlined nexus-link.css */
#game-area-container { /* Renamed from game-container */
    width: 100%;
    max-width: 800px; /* Match canvas base width */
    margin: 0 auto;
    /* padding: 10px; Removed padding to allow borders to align */
    display: flex; /* Use flexbox for layout */
    flex-direction: column; /* Stack vertically */
    align-items: center; /* Center horizontally */
}

canvas {
    background-color: #000;
    border: 4px solid #30363d;
    width: 100%; /* Make canvas responsive */
    display: block;
    image-rendering: pixelated; /* Crisp pixels */
    cursor: crosshair;
    /* Aspect ratio is controlled by JS setting width/height attributes */
}

#game-ui {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    justify-content: space-between;
    padding: 10px;
    background-color: #161b22;
    border: 4px solid #30363d;
    border-bottom: none; /* Remove bottom border */
    font-size: 0.8rem;
    gap: 10px;
    width: 100%; /* Take full width */
}

#game-ui > div {
    min-width: 120px; /* Ensure items don't get too cramped */
    flex-grow: 1; /* Allow items to grow */
    text-align: center; /* Center text within each item */
}
/* Span inside UI for values */
#game-ui span {
    color: #facc15; /* Yellow */
}


#tower-palette {
    display: grid; /* Use grid for compact layout */
    grid-template-columns: repeat(5, 1fr); /* UPDATED: Force 5 columns */
    gap: 8px; /* Tighter gap */
    padding: 10px; /* Reduced padding */
    background-color: #161b22;
    border: 4px solid #30363d;
    border-top: none; /* Remove top border */
    width: 100%; /* Take full width */
}

#tower-palette .btn {
    font-size: 0.6rem; /* Smaller font for cost */
    padding: 8px; /* Adjust padding for icons */
    position: relative;
    min-width: 0; /* Remove min-width */
    height: 60px; /* Make buttons square-ish */
    display: flex; /* Use flex to center icon/text */
    flex-direction: column; /* Stack icon and cost */
    align-items: center; /* Center horizontally */
    justify-content: center; /* Center vertically */
    line-height: 1.2; /* Adjust line height */
    /* Inherit button styles from base */
}

/* NEW: Style for desktop text labels */
.btn .build-label {
    font-size: 0.7rem; 
    display: block; /* Will be controlled by sm:block */
    color: #c9d1d9; 
    line-height: 1.1;
    margin-bottom: 2px; /* Space between label and cost */
}


/* NEW: SVG Icon styles within buttons */
#tower-palette .btn svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px; /* Space between icon and cost */
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Specific icon adjustments */
#tower-palette .btn #icon-sell svg {
    stroke-width: 1.5;
}
#tower-palette .btn #icon-start-wave svg {
    fill: currentColor;
    stroke: none;
    width: 20px;
    height: 20px;
}
#tower-palette .btn #icon-power-large svg {
     stroke-width: 1.5;
}
#tower-palette .btn #icon-minigun svg {
    fill: currentColor;
    stroke: none;
}


/* Style for the button when it's selected for building or selling */
#tower-palette .btn.selected {
     background-color: #f97316; /* Orange hover from style guide */
     border-color: #f97316;
     box-shadow: 0 0 15px #f97316;
}
/* Special style for sell button when selected */
#tower-palette #sell-tower-btn.selected {
     background-color: #da3633; /* Red */
     border-color: #f85149;
     box-shadow: 0 0 15px #f85149;
}


.btn .cost {
    font-size: 0.6rem;
    display: block;
    margin-top: 4px;
    color: #8b949e; /* Dimmer color for cost */
}

.btn .unlock-text {
    font-size: 0.6rem;
    display: block;
    margin-top: 4px;
    color: #ff00cc; /* Magenta */
}

/* Modal Styling */
#game-modal {
    position: fixed;
    inset: 0;
    background: rgba(13, 17, 23, 0.9); /* Darker overlay */
    display: flex; /* Controlled by JS */
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

#game-modal-content {
    /* Use the game-card style */
    background-color: #161b22;
    border: 4px solid #30363d;
    padding: 30px;
    text-align: center;
    max-width: 500px;
    width: 100%;
    border-radius: 8px; /* Added rounding */
}

#game-modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #ff00cc; /* Magenta */
}

#game-modal-content p {
    font-size: 0.8rem;
    line-height: 1.6;
    margin-bottom: 30px;
}

/* Hide game title by default, show on game over */
#game-title.hidden {
    display: none;
}

.hidden {
    display: none !important; /* Use important to override potential conflicts */
}

/* Error flash animation for buttons */
@keyframes errorFlash {
  0%, 100% { border-color: #f85149; box-shadow: 0 0 8px #f85149; }
  50% { border-color: #30363d; box-shadow: 4px 4px #000; }
}

.btn.error-flash {
  animation: errorFlash 0.3s ease-out;
}

/* START: MODIFICATION FOR MOBILE PALETTE */
@media (max-width: 639px) { /* sm: breakpoint */
    
    /* --- FIX: Compact Tower Palette for Mobile --- */
    #tower-palette {
        padding: 4px; /* Reduce padding from 10px */
        gap: 4px;     /* Reduce spacing between buttons from 8px */
    }

    #tower-palette .btn {
        height: 40px;       /* Reduce button height from 60px */
        padding: 4px;       /* Reduce padding from 8px */
        font-size: 0.5rem;  /* Reduce base text size from 0.6rem */
        line-height: 1.1;   /* Tighten line height */
    }

    /* Hide the text label and cost by default on mobile */
    #tower-palette .btn .build-label {
        display: none;
    }
    
    #tower-palette .btn .cost,
    #tower-palette .btn .unlock-text {
        font-size: 0.5rem; /* Ensure cost/unlock text is also small */
        margin-top: 2px;   /* Reduce top margin from 4px */
    }

    #tower-palette .btn svg {
        width: 10px;        /* Reduce icon size from 24px */
        height: 10px;       /* Reduce icon size from 24px */
        margin-bottom: 2px; /* Reduce space between icon and text */
    }

    /* --- Special Case: START WAVE button --- */
    /* We WANT text for this one */
    #tower-palette #start-wave .build-label,
    #tower-palette #start-wave .cost {
            display: block; /* Show the text for the wave button */
            font-size: 0.6rem;
            line-height: 1.2;
            margin-top: 0;
    }
    
    /* Hide the desktop label, show the mobile one (which is .cost) */
    #tower-palette #start-wave #start-wave-text-desktop {
        display: none;
    }

    /* Hide the icon on the wave button to make space for text */
    #tower-palette #start-wave svg {
        display: none;
    }
    
    /* Adjust the JS-driven text span */
    #tower-palette #start-wave #start-wave-text {
            text-align: center;
            color: #ffffff; /* Make it white like button text */
    }
}
/* END: MODIFICATION FOR MOBILE PALETTE */