* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'VT323', monospace;
    background: linear-gradient(135deg, #0d0a08 0%, #1a1410 50%, #2a1f14 100%);
    color: #c4a747;
    min-height: 100vh;
    overflow-x: hidden;
}

#game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#header {
    text-align: center;
    padding: 15px 0;
    border-bottom: 3px solid #3d2817;
    background: linear-gradient(180deg, #2a1f14 0%, transparent 100%);
}

#header h1 {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(18px, 4vw, 32px);
    color: #c4a747;
    text-shadow: 3px 3px 0 #3d2817, 0 0 20px rgba(196, 167, 71, 0.5);
    letter-spacing: 4px;
}

#header .subtitle {
    font-size: clamp(12px, 2vw, 18px);
    color: #8b7355;
    margin-top: 5px;
}

#main-content {
    flex: 1;
    display: flex;
    gap: 15px;
    padding: 15px 0;
}

#canvas-container {
    flex: 7;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #0d0a08;
    border: 4px solid #3d2817;
    border-radius: 8px;
    padding: 10px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
}

#canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#ui-panel {
    flex: 3;
    min-width: 220px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#ui-panel section {
    background: linear-gradient(180deg, #2a1f14 0%, #1a1410 100%);
    border: 3px solid #3d2817;
    border-radius: 6px;
    padding: 12px;
}

#ui-panel h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: #c4a747;
    margin-bottom: 10px;
    text-shadow: 1px 1px 0 #3d2817;
}

#ui-panel h2 .hint {
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: #8b7355;
}

.stat-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.stat-label {
    width: 30px;
    font-size: 14px;
    color: #8b7355;
}

.bar-container {
    flex: 1;
    height: 16px;
    background: #1a1410;
    border: 2px solid #3d2817;
    border-radius: 3px;
    overflow: hidden;
}

.bar {
    height: 100%;
    transition: width 0.3s ease;
}

.bar.hp {
    background: linear-gradient(180deg, #cc4444 0%, #8b0000 100%);
    box-shadow: 0 0 8px rgba(139, 0, 0, 0.5);
}

.bar.stamina {
    background: linear-gradient(180deg, #c4a747 0%, #8b7355 100%);
    box-shadow: 0 0 8px rgba(196, 167, 71, 0.5);
}

.bar.hunger {
    background: linear-gradient(180deg, #ff9933 0%, #cc6600 100%);
    box-shadow: 0 0 8px rgba(255, 153, 51, 0.5);
}

.bar.hunger.critical {
    background: linear-gradient(180deg, #ff4444 0%, #8b0000 100%);
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

.stat-value {
    width: 55px;
    text-align: right;
    font-size: 14px;
    color: #c4a747;
}

.floor-info {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    color: #c4a747;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #3d2817;
}

.equipment-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: #1a1410;
    border: 2px solid #3d2817;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 14px;
}

.slot-icon {
    font-size: 18px;
}

#inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.inv-slot {
    aspect-ratio: 1;
    background: #1a1410;
    border: 2px solid #3d2817;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.inv-slot:hover {
    border-color: #c4a747;
}

.inv-slot.selected {
    border-color: #ffcc00;
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
    background: #2a2014;
}

#inventory-grid.inventory-open .inv-slot {
    animation: inventoryPulse 1s infinite alternate;
}

@keyframes inventoryPulse {
    from { box-shadow: 0 0 5px rgba(196, 167, 71, 0.3); }
    to { box-shadow: 0 0 15px rgba(196, 167, 71, 0.6); }
}

#event-log {
    height: 150px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.4;
    padding-right: 5px;
}

#event-log::-webkit-scrollbar {
    width: 6px;
}

#event-log::-webkit-scrollbar-track {
    background: #1a1410;
}

#event-log::-webkit-scrollbar-thumb {
    background: #3d2817;
    border-radius: 3px;
}

#controls-section {
    padding: 10px !important;
}

.control-hint {
    font-size: 12px;
    color: #8b7355;
    margin-bottom: 4px;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 10, 8, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(180deg, #2a1f14 0%, #1a1410 100%);
    border: 4px solid #3d2817;
    border-radius: 12px;
    padding: 30px 40px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

.modal-content h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    color: #c4a747;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 #3d2817;
}

.modal-content p {
    font-size: 16px;
    color: #8b7355;
    margin-bottom: 15px;
}

.modal-content.death h2 {
    color: #ff4444;
}

.seed-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    align-items: center;
    justify-content: center;
}

.seed-input-group label {
    color: #8b7355;
    font-size: 16px;
}

.seed-input-group input {
    flex: 1;
    max-width: 150px;
    padding: 8px 12px;
    font-family: 'VT323', monospace;
    font-size: 16px;
    background: #1a1410;
    border: 2px solid #3d2817;
    border-radius: 4px;
    color: #c4a747;
    text-transform: uppercase;
}

.seed-input-group input:focus {
    outline: none;
    border-color: #c4a747;
}

.seed-input-group button {
    padding: 8px 12px;
    font-size: 18px;
    background: #3d2817;
    border: 2px solid #5c4a3d;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.seed-input-group button:hover {
    background: #5c4a3d;
}

.big-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 15px 30px;
    background: linear-gradient(180deg, #c4a747 0%, #8b7355 100%);
    border: 3px solid #3d2817;
    border-radius: 6px;
    color: #1a1410;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
}

.big-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(196, 167, 71, 0.5);
}

.big-btn:active {
    transform: scale(0.98);
}

#final-stats {
    margin: 20px 0;
    padding: 15px;
    background: #1a1410;
    border: 2px solid #3d2817;
    border-radius: 6px;
}

#final-stats p {
    margin: 8px 0;
    font-size: 14px;
}

#highscore-display {
    margin-top: 20px;
    padding: 10px;
    background: rgba(196, 167, 71, 0.1);
    border-radius: 4px;
}

#highscore-display p {
    color: #c4a747;
    margin: 0;
    font-size: 14px;
}

footer {
    text-align: center;
    padding: 15px;
    border-top: 2px solid #3d2817;
}

footer a {
    color: #8b7355;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

footer a:hover {
    color: #c4a747;
}

@media (max-width: 900px) {
    #main-content {
        flex-direction: column;
    }
    
    #canvas-container {
        order: 1;
    }
    
    #ui-panel {
        order: 2;
        max-width: none;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    #ui-panel section {
        flex: 1;
        min-width: 200px;
    }
    
    #log-section {
        flex-basis: 100%;
    }
    
    #event-log {
        height: 100px;
    }
}

@media (max-width: 600px) {
    #game-container {
        padding: 5px;
    }
    
    #header {
        padding: 10px 0;
    }
    
    #main-content {
        gap: 10px;
        padding: 10px 0;
    }
    
    #ui-panel section {
        padding: 8px;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .big-btn {
        font-size: 10px;
        padding: 12px 20px;
    }
}