@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
    background: linear-gradient(135deg, #0a0a12 0%, #1a1a2e 50%, #0d0d1a 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', monospace;
    padding: 10px;
    overflow-x: hidden;
}

#game-container {
    background: linear-gradient(180deg, #1a1a2e 0%, #0d0d15 100%);
    border: 4px solid #6b3fa0;
    border-radius: 8px;
    box-shadow: 
        0 0 30px rgba(107, 63, 160, 0.4),
        0 0 60px rgba(107, 63, 160, 0.2),
        inset 0 0 80px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    max-width: 100%;
    width: 808px;
}

#title-bar {
    background: linear-gradient(90deg, #2d1b4e, #6b3fa0, #2d1b4e);
    color: #ffd93d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    font-size: 14px;
    letter-spacing: 3px;
    text-shadow: 2px 2px 0 #000, 0 0 10px rgba(255, 217, 61, 0.5);
    border-bottom: 3px solid #ffd93d;
}

#mini-map-toggle {
    cursor: pointer;
    font-size: 18px;
    transition: transform 0.2s;
}

#mini-map-toggle:hover {
    transform: scale(1.2);
}

#dialogue-bar {
    background: linear-gradient(180deg, #0a0a0f 0%, #000 100%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    min-height: 60px;
    border-bottom: 2px solid #222;
}

#character-portrait {
    width: 42px;
    height: 42px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: 2px solid #4ecdc4;
    border-radius: 4px;
    flex-shrink: 0;
    display: none;
}

#dialogue-text {
    color: #4ecdc4;
    font-size: 9px;
    line-height: 1.7;
    text-shadow: 0 0 8px rgba(78, 205, 196, 0.6);
    flex: 1;
}

#canvas-wrapper {
    position: relative;
    width: 100%;
}

#canvas {
    display: block;
    background: #0d0d15;
    cursor: crosshair;
    width: 100%;
    height: auto;
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 217, 61, 0.8);
    color: #1a1a2e;
    padding: 20px 12px;
    font-size: 24px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    animation: arrowPulse 1.5s ease-in-out infinite;
    z-index: 10;
}

.nav-arrow.hidden {
    display: none;
}

.nav-arrow:hover {
    background: #ffd93d;
    transform: translateY(-50%) scale(1.1);
}

#nav-arrow-left {
    left: 8px;
}

#nav-arrow-right {
    right: 8px;
}

@keyframes arrowPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

#mini-map {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid #6b3fa0;
    border-radius: 4px;
    padding: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    z-index: 20;
}

#mini-map.hidden {
    display: none;
}

.map-room {
    padding: 6px 8px;
    font-size: 6px;
    color: #666;
    background: #1a1a2e;
    border: 1px solid #333;
    text-align: center;
    border-radius: 2px;
}

.map-room.visited {
    color: #4ecdc4;
    border-color: #4ecdc4;
}

.map-room.current {
    color: #ffd93d;
    border-color: #ffd93d;
    background: #2d1b4e;
    animation: currentRoomPulse 1s ease-in-out infinite;
}

.map-room.locked {
    color: #8b0000;
    border-color: #8b0000;
}

@keyframes currentRoomPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 217, 61, 0.5); }
    50% { box-shadow: 0 0 12px rgba(255, 217, 61, 0.8); }
}

#action-display {
    background: linear-gradient(180deg, #1a1a2e 0%, #0d0d15 100%);
    color: #ffd93d;
    text-align: center;
    padding: 8px;
    font-size: 10px;
    text-shadow: 0 0 8px rgba(255, 217, 61, 0.4);
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
}

#ui-container {
    display: flex;
    background: linear-gradient(180deg, #16213e 0%, #0d0d15 100%);
    padding: 10px;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: space-between;
}

#verb-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    flex: 1;
    min-width: 240px;
}

.verb-btn {
    background: linear-gradient(180deg, #3d2466 0%, #2d1b4e 100%);
    color: #aaa;
    border: 2px solid #4a2c82;
    padding: 10px 6px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.15s;
    text-shadow: 1px 1px 0 #000;
    white-space: nowrap;
}

.verb-btn:hover {
    background: linear-gradient(180deg, #5a3d80 0%, #4a2c82 100%);
    color: #fff;
    border-color: #8b5fbf;
}

.verb-btn.active {
    background: linear-gradient(180deg, #7b4fbf 0%, #5a3d80 100%);
    color: #ffd93d;
    border-color: #ffd93d;
    box-shadow: 0 0 12px rgba(255, 217, 61, 0.5);
}

#inventory-panel {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 200px;
    justify-content: flex-end;
}

.inv-arrow {
    color: #4ecdc4;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    transition: all 0.2s;
}

.inv-arrow:hover {
    color: #ffd93d;
    transform: scale(1.2);
}

#inventory-slots {
    display: flex;
    gap: 5px;
}

.inventory-slot {
    width: 44px;
    height: 44px;
    background: linear-gradient(180deg, #1a1a2e 0%, #0d0d15 100%);
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    border-radius: 4px;
}

.inventory-slot:hover {
    border-color: #4ecdc4;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
}

.inventory-slot.selected {
    border-color: #ffd93d;
    box-shadow: 0 0 15px rgba(255, 217, 61, 0.7);
    animation: selectedPulse 0.8s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 217, 61, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 217, 61, 0.9); }
}

.inventory-slot img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

#controls-info {
    background: #0a0a0f;
    color: #555;
    text-align: center;
    padding: 8px;
    font-size: 7px;
    border-top: 1px solid #222;
}

footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 808px;
    padding: 15px 10px;
    color: #555;
    font-size: 8px;
    flex-wrap: wrap;
    gap: 10px;
}

footer a {
    color: #4ecdc4;
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: #ffd93d;
    text-decoration: underline;
}

#game-controls {
    display: flex;
    gap: 6px;
}

#game-controls button {
    background: linear-gradient(180deg, #1a1a2e 0%, #0d0d15 100%);
    color: #4ecdc4;
    border: 1px solid #333;
    padding: 6px 10px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
}

#game-controls button:hover {
    background: #2d1b4e;
    border-color: #4ecdc4;
}

#hint-btn {
    animation: hintGlow 1s ease-in-out infinite;
}

@keyframes hintGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 217, 61, 0.3); }
    50% { box-shadow: 0 0 15px rgba(255, 217, 61, 0.8); }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(180deg, #2d1b4e 0%, #1a1a2e 100%);
    border: 3px solid #6b3fa0;
    padding: 30px;
    text-align: center;
    border-radius: 8px;
    max-width: 90%;
}

.modal-content h2 {
    color: #ffd93d;
    font-size: 14px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 #000;
}

.save-slots {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.save-slot, .load-slot {
    background: linear-gradient(180deg, #3d2466 0%, #2d1b4e 100%);
    color: #4ecdc4;
    border: 2px solid #4a2c82;
    padding: 12px 20px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.save-slot:hover, .load-slot:hover:not(:disabled) {
    background: #5a3d80;
    border-color: #ffd93d;
    color: #ffd93d;
}

.load-slot:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-close {
    background: linear-gradient(180deg, #4ecdc4 0%, #26a69a 100%);
    color: #000;
    border: none;
    padding: 10px 25px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
}

.modal-close:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(78, 205, 196, 0.6);
}

/* Win Screen */
#win-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#win-screen.hidden {
    display: none;
}

#win-content {
    background: linear-gradient(180deg, #2d1b4e 0%, #1a1a2e 100%);
    border: 4px solid #ffd93d;
    padding: 40px;
    text-align: center;
    max-width: 90%;
    border-radius: 8px;
    animation: winPulse 1s ease-in-out infinite alternate;
}

@keyframes winPulse {
    from { box-shadow: 0 0 30px rgba(255, 217, 61, 0.5); }
    to { box-shadow: 0 0 60px rgba(255, 217, 61, 0.9); }
}

#win-content h1 {
    color: #ffd93d;
    font-size: 16px;
    margin-bottom: 15px;
    text-shadow: 2px 2px 0 #000;
}

#win-animation {
    font-size: 24px;
    margin: 15px 0;
    animation: celebrationSpin 2s linear infinite;
}

@keyframes celebrationSpin {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(5deg); }
    50% { transform: scale(1) rotate(0deg); }
    75% { transform: scale(1.1) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

#win-content p {
    color: #4ecdc4;
    font-size: 10px;
    margin: 15px 0;
    line-height: 1.8;
}

#play-again-btn {
    background: linear-gradient(180deg, #4ecdc4 0%, #26a69a 100%);
    color: #000;
    border: none;
    padding: 15px 30px;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.2s;
    border-radius: 4px;
}

#play-again-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 25px rgba(78, 205, 196, 0.8);
}

.win-footer {
    margin-top: 30px !important;
    color: #555 !important;
    font-size: 8px !important;
}

/* Responsive */
@media (max-width: 850px) {
    #canvas {
        width: 100%;
        height: auto;
    }
    
    #title-bar {
        font-size: 11px;
        letter-spacing: 1px;
    }
    
    #ui-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    #verb-panel {
        grid-template-columns: repeat(3, 1fr);
    }
    
    #inventory-panel {
        justify-content: center;
    }
    
    footer {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 500px) {
    #title-bar {
        font-size: 9px;
        padding: 10px;
    }
    
    #dialogue-text {
        font-size: 7px;
    }
    
    .verb-btn {
        padding: 8px 4px;
        font-size: 7px;
    }
    
    .inventory-slot {
        width: 38px;
        height: 38px;
    }
    
    .inventory-slot img {
        width: 28px;
        height: 28px;
    }
    
    #controls-info {
        font-size: 6px;
    }
    
    #win-content h1 {
        font-size: 12px;
    }
    
    #game-controls button {
        padding: 4px 6px;
        font-size: 12px;
    }
    
    .nav-arrow {
        padding: 15px 8px;
        font-size: 18px;
    }
}