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

body {
    background-color: #222;
    color: #fff;
    font-family: monospace;
    font-size: 16px;
    line-height: 1.5;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

#game-container {
    display: flex;
    flex-direction: column;
    width: 800px;
    height: 600px;
    border: 1px solid #444;
    background-color: #111;
}

#game-map {
    flex: 1;
    overflow: hidden;
    background-color: #000;
    padding: 5px;
    display: flex;
    flex-direction: column;
}

.map-row {
    display: flex;
    height: 20px;
}

.map-cell {
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

#game-ui {
    height: 150px;
    background-color: #222;
    border-top: 1px solid #444;
    display: flex;
    flex-direction: column;
}

#stats-display {
    display: flex;
    justify-content: space-around;
    padding: 5px;
    background-color: #333;
    border-bottom: 1px solid #444;
}

#message-log {
    flex: 1;
    padding: 5px;
    overflow-y: auto;
    font-size: 14px;
}

.message {
    margin-bottom: 2px;
}

.message-info {
    color: #ccc;
}

.message-important {
    color: #ff6;
    font-weight: bold;
}

.message-danger {
    color: #f66;
    font-weight: bold;
}

.message-sign {
    color: #6cf;
    font-style: italic;
}

.message-item {
    color: #6f6;
}

.message-npc {
    color: #f9f;
}

/* Panels */
.panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #333;
    border: 2px solid #555;
    padding: 10px;
    z-index: 10;
    width: 400px;
    max-height: 500px;
    overflow-y: auto;
}

.panel h3 {
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.hidden {
    display: none !important;
}

/* Loading indicator */
.loading {
    color: #fff;
    font-size: 18px;
    text-align: center;
    padding: 20px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Inventory, Spellbook, and Dialogue UIs */
.inventory-ui,
.spellbook-ui,
.dialogue-ui {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    border-left: 2px solid #666;
    padding: 15px;
    width: 300px;
    z-index: 100;
    font-family: monospace;
    color: #fff;
    display: flex;
    flex-direction: column;
}

/* Dialogue UI specific styles */
.dialogue-ui {
    top: auto;
    right: auto;
    height: auto;
    width: auto;
    bottom: 150px;
    left: 0;
    right: 0;
    margin: 0 auto;
    max-width: 80%;
    background-color: rgba(0, 0, 0, 0.85);
    border: 2px solid #666;
    border-radius: 5px;
    z-index: 200;
}

.inventory-header,
.spellbook-header,
.dialogue-header {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    border-bottom: 1px solid #666;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.dialogue-content {
    padding: 15px;
    font-size: 16px;
    line-height: 1.5;
    min-height: 80px;
}

.dialogue-footer {
    text-align: center;
    font-size: 12px;
    color: #999;
    padding-top: 10px;
    border-top: 1px solid #666;
}

.inventory-items,
.spellbook-spells {
    margin: 10px 0;
    flex: 1;
    overflow-y: auto;
}

.inventory-item,
.spellbook-spell {
    display: flex;
    align-items: center;
    padding: 8px 5px;
    border-bottom: 1px solid #333;
    position: relative;
}

.inventory-item.selected,
.spellbook-spell.selected {
    background-color: #444;
    border: 1px solid #aaa;
    border-radius: 3px;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

.inventory-item.selected::before,
.spellbook-spell.selected::before {
    content: '➤';
    position: absolute;
    left: -5px;
    color: #ff0;
}

.spellbook-spell.disabled {
    opacity: 0.5;
    color: #888;
}

.spell-description {
    margin-top: 15px;
    padding: 10px;
    background-color: rgba(0, 0, 50, 0.3);
    border: 1px solid #446;
    border-radius: 3px;
    font-style: italic;
    color: #aaf;
}

.item-symbol,
.spell-element {
    width: 20px;
    height: 20px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin-right: 10px;
    font-weight: bold;
}

.item-name,
.spell-name {
    flex: 1;
}

.item-type,
.spell-info {
    color: #aaa;
    font-size: 12px;
    margin-left: 15px;
}

.inventory-footer,
.spellbook-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #666;
    font-size: 12px;
    color: #aaa;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px;
}