/* --- Core Responsive Layout --- */
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
    font-family: 'Segoe UI', sans-serif;
    background-color: #111;
    color: #f1f1f1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
#main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    max-width: 100%;
    max-height: 100%;
}

/* --- UI Elements --- */
h1 { font-size: 2.5em; margin-bottom: 10px; color: #ff6b6b; }
p { font-size: 1.2em; color: #aaa; margin-top: 0; }
#score-display {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    margin-top: 15px;
    font-size: 1.5em;
    font-weight: bold;
}
#score-display div:last-child { color: #f1c40f; }

/* --- Game Board --- */
#game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    width: clamp(320px, 80vmin, 600px);
    height: clamp(320px, 80vmin, 600px);
    background-color: #000;
    border: 5px solid #444;
    padding: 5px;
}
.grid-cell {
    background-color: #333;
    border-radius: 5px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 5vmin, 2rem);
    position: relative;
}
.grid-cell:not(.movable) { cursor: not-allowed; }

/* --- Tile States & Animations --- */
.grid-cell.player::after { content: '🙂'; position: absolute; animation: hop-in 0.3s ease-out; }
.grid-cell.player.game-over::after { animation: sink 0.5s ease-in forwards; }
.grid-cell.safe { background-color: #333; }
.grid-cell.movable { background-color: #4a4a4a; cursor: pointer; }
.grid-cell.movable:hover { background-color: #555; transform: scale(1.05); box-shadow: 0 0 10px #3498db; }
.grid-cell.warning { background-color: #e74c3c; animation: pulse-warning 1s infinite; }
.grid-cell.lava { background-color: #f39c12; }
.grid-cell.cooling { animation: pulse-cooling 1s infinite; }

@keyframes hop-in { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes sink { from { transform: scale(1); opacity: 1; } to { transform: scale(0); opacity: 0; } }
@keyframes pulse-warning { 50% { opacity: 0.6; } }
@keyframes pulse-cooling { 50% { background-color: #b1700c; } }

/* --- Game Over Overlay --- */
#game-over-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.85); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; font-size: 2em; animation: fade-in 0.5s; z-index: 20;}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
#game-over-overlay p { font-size: 0.8em; }
#restart-btn { margin-top: 20px; padding: 15px 30px; font-size: 0.8em; border: none; border-radius: 10px; background-color: #ff6b6b; color: white; cursor: pointer; transition: background-color 0.2s; }
#restart-btn:hover { background-color: #e74c3c; }
.hidden { display: none !important; }