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

body {
    font-family: 'Georgia', serif;
    background: linear-gradient(45deg, #2d1b69, #1a1a2e);
    color: #f3f4f6;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Screen management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.screen.active {
    display: flex;
}

/* Main menu */
#main-menu {
    justify-content: center;
    align-items: center;
    background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('/api/retrodiffusion/image/512/512/texture?prompt=middle+earth+shire+hobbiton+hills+peaceful+landscape');
    background-size: cover;
    background-position: center;
}

.menu-background {
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #d4af37;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

.game-title {
    font-size: 3rem;
    color: #d4af37;
    text-shadow: 2px 2px 4px #000;
    margin-bottom: 30px;
    font-weight: bold;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-btn {
    background: linear-gradient(45deg, #8b4513, #d4af37);
    color: #fff;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px #000;
    min-width: 200px;
}

.menu-btn:hover {
    background: linear-gradient(45deg, #d4af37, #ffd700);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.menu-btn:disabled {
    background: #666;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Character creation */
#character-creation {
    justify-content: center;
    align-items: center;
    background: linear-gradient(rgba(0,0,0,0.8), rgba(0,0,0,0.8)), url('/api/retrodiffusion/image/512/512/texture?prompt=rivendell+elven+architecture+peaceful+valley');
    background-size: cover;
}

.creation-panel {
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #d4af37;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    max-width: 800px;
    width: 90%;
}

.creation-panel h2 {
    color: #d4af37;
    font-size: 2rem;
    margin-bottom: 30px;
}

.race-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.race-option {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #666;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.race-option:hover {
    border-color: #d4af37;
    background: rgba(212, 175, 55, 0.2);
}

.race-option.selected {
    border-color: #d4af37;
    background: rgba(212, 175, 55, 0.3);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.race-option img {
    width: 64px;
    height: 64px;
    margin-bottom: 10px;
}

.race-option h3 {
    color: #d4af37;
    margin-bottom: 5px;
}

.race-option p {
    font-size: 0.9rem;
    color: #ccc;
}

/* Game screen */
#game-screen {
    position: relative;
}

#canvas {
    border: 2px solid #d4af37;
    background: #2d5016;
    display: block;
    margin: 0 auto;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#ui-overlay > * {
    pointer-events: auto;
}

#character-info {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #d4af37;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
}

#character-portrait {
    width: 48px;
    height: 48px;
    border: 1px solid #666;
    border-radius: 4px;
    overflow: hidden;
}

#character-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.bar-label {
    color: #fff;
    font-size: 0.8rem;
    min-width: 20px;
}

.bar {
    width: 80px;
    height: 12px;
    background: #333;
    border: 1px solid #666;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

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

.health-bar .bar-fill {
    background: linear-gradient(90deg, #dc2626, #ef4444);
}

.mana-bar .bar-fill {
    background: linear-gradient(90deg, #2563eb, #3b82f6);
}

#level-info {
    color: #d4af37;
    font-weight: bold;
    font-size: 0.9rem;
}

#quest-tracker {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #d4af37;
    border-radius: 8px;
    padding: 10px;
    min-width: 200px;
}

#quest-tracker h3 {
    color: #d4af37;
    margin-bottom: 10px;
    font-size: 1rem;
}

.quest-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 5px;
    font-size: 0.8rem;
}

#quick-bar {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
}

.quick-slot {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #666;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
}

.quick-slot:hover {
    border-color: #d4af37;
}

/* Inventory panel */
.panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #d4af37;
    border-radius: 10px;
    padding: 20px;
    min-width: 400px;
}

.panel.hidden {
    display: none;
}

.panel h3 {
    color: #d4af37;
    margin-bottom: 15px;
    text-align: center;
}

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

.inventory-slot {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #666;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.inventory-slot:hover {
    border-color: #d4af37;
    background: rgba(212, 175, 55, 0.2);
}

.inventory-slot img {
    max-width: 90%;
    max-height: 90%;
}

#equipment-slots {
    display: flex;
    justify-content: space-around;
}

.equipment-slot {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #666;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    text-align: center;
    cursor: pointer;
}

.equipment-slot:hover {
    border-color: #d4af37;
}

/* Dialogue system */
#dialogue-box {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    background: rgba(0, 0, 0, 0.9);
    border-top: 3px solid #d4af37;
    padding: 20px;
}

#dialogue-box.hidden {
    display: none;
}

#dialogue-content {
    display: flex;
    height: 100%;
    gap: 20px;
}

#npc-portrait {
    width: 80px;
    height: 80px;
    border: 2px solid #d4af37;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

#npc-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#dialogue-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#npc-name {
    color: #d4af37;
    font-weight: bold;
    font-size: 1.1rem;
}

#dialogue-message {
    flex: 1;
    color: #f3f4f6;
    line-height: 1.4;
}

#dialogue-choices {
    display: flex;
    gap: 10px;
}

.dialogue-choice {
    background: rgba(212, 175, 55, 0.2);
    border: 1px solid #d4af37;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dialogue-choice:hover {
    background: rgba(212, 175, 55, 0.4);
}

/* Settings screen */
#settings-screen {
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.8);
}

.settings-panel {
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #d4af37;
    border-radius: 15px;
    padding: 30px;
    min-width: 400px;
}

.settings-panel h2 {
    color: #d4af37;
    margin-bottom: 20px;
    text-align: center;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    color: #f3f4f6;
    margin-bottom: 5px;
}

.setting-item input[type="range"] {
    width: 100%;
}

.setting-item select {
    width: 100%;
    background: #333;
    color: #fff;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 8px;
}

/* Controls info */
#controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    text-align: center;
    border-top: 1px solid #666;
}

.control-info {
    font-size: 0.9rem;
    color: #ccc;
}

/* Responsive design */
@media (max-width: 768px) {
    .race-selection {
        grid-template-columns: 1fr;
    }
    
    #canvas {
        width: 100vw;
        height: calc(100vh - 60px);
    }
    
    .creation-panel {
        width: 95%;
        padding: 20px;
    }
    
    .game-title {
        font-size: 2rem;
    }
}