/* WONGLE: Dungeon Crawler Edition 
   Restored Original Arcade Dimensions
*/
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* --- Core Layout --- */
#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100dvh;
    width: 100%;
    max-width: 600px;
    padding: 10px;
    padding-top: 20px;
    position: relative;
    margin: 0 auto;
    box-sizing: border-box;
    font-family: 'Press Start 2P', cursive;
    background-color: #0d1117;
    color: #e6edf3;
    overflow: hidden;
}

/* --- HUD --- */
#dungeon-hud {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 500px; /* Matches keyboard width */
    margin-bottom: 5px;
    padding: 8px;
    background: #161b22;
    border-bottom: 2px solid #30363d;
    flex-shrink: 0;
    box-sizing: border-box;
}

.hud-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-size: 0.6rem; 
    color: #8b949e;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 4px;
}

.hud-value {
    font-size: 1rem; 
    font-weight: bold;
}
.hud-value.health { color: #ef4444; }
.hud-value.depth { color: #eab308; }

#turn-indicator {
    background: #1f6feb;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    display: none;
}

/* --- Dungeon Map (5x5 Fixed Grid) --- */
#dungeon-map {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 4px;
    width: 100%;
    max-width: 300px; /* Constrained for 5x5 look */
    aspect-ratio: 1;  /* Square map */
    background: #010409;
    border: 2px solid #30363d;
    margin-bottom: 10px;
    padding: 4px;
    border-radius: 4px;
    flex-shrink: 0;
    box-sizing: border-box;
}

/* Map Nodes */
.map-node {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: #000;
    border: 2px solid #30363d;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.6rem; 
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #8b949e;
    user-select: none;
}

.map-node:hover { transform: scale(1.05); z-index: 10; border-color: #8b949e; }

.map-node.active-node { 
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
    z-index: 5;
    transform: scale(1.1);
}

/* Status Colors */
.map-node.solved { background: #238636; border-color: #2ea043; color: white; }
.map-node.partial { background: #d29922; border-color: #eab308; color: white; }
.map-node.unvisited { background: #161b22; border-color: #30363d; }

/* Item Nodes */
.map-node.item {
    background: #7c3aed; /* Purple */
    border-color: #a78bfa;
    color: #fcd34d; /* Gold Text */
    font-size: 1rem;
    text-shadow: 1px 1px 0 #000;
}
.map-node.item.solved { 
    background: #4c1d95; 
    color: #6b7280; 
    border-color: #4b5563; 
}

/* Fog of War */
.map-node.fog {
    background: #050505;
    border-color: #111;
    cursor: default;
    color: transparent;
}
.map-node.fog:hover { transform: none; border-color: #111; }

/* Exit Node */
.map-node.exit-node {
    border: 3px solid #ec4899; /* Pink Border */
    box-shadow: 0 0 5px #ec4899;
}
.map-node.exit-node.fog { border-color: #111; box-shadow: none; } /* Hide if in fog */

/* Empty slot in grid */
.map-empty {
    background: transparent;
    pointer-events: none;
}

/* --- Message Bar --- */
#message-bar {
    height: 24px;
    color: #fbbf24;
    text-align: center;
    font-size: 0.8rem; 
    font-weight: bold;
    margin-bottom: 5px;
    text-shadow: 1px 1px 0 #000;
    line-height: 24px;
}

/* --- Keyboard --- */
#keyboard-container {
    width: 100%;
    max-width: 500px; 
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
    flex-shrink: 0;
    padding: 5px;
    background: #0d1117;
    box-sizing: border-box;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.key {
    background-color: #8b949e;
    color: white;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    height: 55px; 
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem; 
    border: none;
    box-shadow: 0 2px 0 #161b22;
}

.key:active { transform: translateY(2px); box-shadow: none; }
.key.wide { flex: 1.5; }
.key.correct { background-color: #238636; }
.key.present { background-color: #d29922; }
.key.absent { background-color: #30363d; opacity: 0.5; }

/* --- Dynamic Grid (Bottom) --- */
#grid-container {
    display: flex;
    flex-direction: column;
    gap: 8px; 
    width: 100%;
    max-width: 390px; 
    overflow-y: auto;
    flex-grow: 1;
    padding-bottom: 20px;
    min-height: 0;
    align-items: center; 
}

/* Individual Rows */
.grid-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px; 
    width: 100%;
}

.tile {
    width: 100%;
    aspect-ratio: 1; 
    border: 2px solid #30363d;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem; 
    font-weight: bold;
    text-transform: uppercase;
    background-color: transparent;
    user-select: none;
    box-sizing: border-box;
}

.tile.filled { border-color: #8b949e; animation: pop 0.1s; }
.tile.correct { background-color: #238636; border-color: #238636; color: white; }
.tile.present { background-color: #d29922; border-color: #d29922; color: white; }
.tile.absent { background-color: #30363d; border-color: #30363d; color: #8b949e; }
.tile.hinted { background-color: #1f6feb; border-color: #58a6ff; color: white; } /* Blue for hint */

/* --- Overlays --- */
.game-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(13, 17, 23, 0.98);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    padding: 20px;
    text-align: center;
}

.pixel-title {
    font-size: 2.5rem; 
    color: #22d3ee;
    text-shadow: 4px 4px #161b22;
    margin-bottom: 2rem;
    line-height: 1.2;
    font-family: 'Press Start 2P', cursive;
}

.menu-btn {
    background: #238636;
    color: white;
    border: 4px solid #1a7f37;
    padding: 20px 20px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    margin: 10px;
    width: 250px;
    text-transform: uppercase;
    box-shadow: 0 4px 0 #0f5120;
    line-height: 1.5;
}
.menu-btn:hover { background: #2ea043; transform: scale(1.05); }
.menu-btn:active { transform: translateY(4px); box-shadow: none; }

/* --- Animations --- */
@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes shake { 
    0%, 100% { transform: translateX(0); } 
    25% { transform: translateX(-5px); } 
    75% { transform: translateX(5px); } 
}
.shake { animation: shake 0.3s; }

.float-text {
    position: absolute;
    font-size: 1rem;
    font-weight: bold;
    animation: floatUp 1s forwards;
    pointer-events: none;
    z-index: 100;
    text-shadow: 2px 2px 0 #000;
}
@keyframes floatUp {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-40px); opacity: 0; }
}

/* Mobile Tweaks */
@media (max-width: 450px) {
    .tile { font-size: 1.2rem; }
    .key { height: 45px; font-size: 0.7rem; }
    #dungeon-map { max-width: 250px; }
    .pixel-title { font-size: 1.5rem; }
}