body {
    background-color: #0f172a; /* Slate 900 */
    color: white;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Press Start 2P', monospace, sans-serif; /* Fallback */
    overflow-x: hidden;
    user-select: none;
}



#game-container {
    width: 100%;
    max-width: 600px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto; 

}

#game-wrapper {
    background-color: #111827;
    border: 4px solid #4b5563;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    width: 100%;
    padding: 15px;
    box-sizing: border-box;
    /* Ensure enough height for the grid + new taller logs */
    min-height: 750px; 
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    color: #ef4444; /* Red 500 */
    text-shadow: 2px 2px #7f1d1d;
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.8rem;
}

/* --- HUD --- */
.battle-hud {
    width: 100%;
    margin-bottom: 20px;
}

.bar-container {
    margin-bottom: 15px;
}

.bar-label {
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 8px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- GRID & CARDS --- */
/* --- Embedded Responsive Styles --- */
#game-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px; /* Reduced gap for mobile */
    width: 100%;
    max-width: 380px; 
    margin: 0 auto;
    perspective: 1000px;
}

.card {
    background-color: #1f2937;
    border: 2px solid #4b5563;
    border-radius: 6px;
    aspect-ratio: 1 / 1; /* Forces square shape */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem; /* Smaller icons for mobile */
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
}


.card:hover {
    border-color: #9ca3af;
}

.card.matched {
    opacity: 0.5;
    pointer-events: none;
}


/* --- LOG & MENU --- */
#battle-log {
    /* Increased height for ~5 lines of text */
    height: 110px;
    width: 100%;
    border-top: 2px solid #374151;
    margin-top: auto; /* Push to bottom */
    padding-top: 15px;
    font-size: 0.8rem; /* Larger text */
    line-height: 1.4;
    color: #9ca3af;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* New messages at bottom */
    font-family: 'Press Start 2P', monospace, sans-serif;
    overflow: hidden;
}

.log-msg { 
    margin: 2px 0; 
    padding-left: 10px;
}
.log-bad { color: #f87171; }
.log-good { color: #4ade80; }
.log-info { color: #fbbf24; }

.overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.95);
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.btn {
    background-color: #3b82f6;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
    text-transform: uppercase;
    box-shadow: 0 4px 0 #1d4ed8;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #1d4ed8;
}

/* Floating damage numbers */
.floater {
    position: fixed;
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    text-shadow: 2px 2px 0 #000;
    transition: transform 1s ease-out, opacity 1s ease-out;
    z-index: 100;
}

/* Scale up for larger screens */
@media (min-width: 500px) {
    #game-grid { gap: 12px; max-width: 450px; }
    .card { font-size: 2rem; border-radius: 8px; }
}