:root {
    --bg-dark: #0f0e0e;
    --text-gold: #d4af37;
    --text-dim: #a8a8a8;
    --parchment: #f0e6d2;
    --parchment-dark: #e6dcc8;
    --border-gold: #d4af37;
    --border-dark: #2c2c2c;
    --accent-red: #8a2be2;
    /* Mystical purple default, can change */
    --accent-glow: rgba(212, 175, 55, 0.3);

    --font-heading: 'Cinzel', serif;
    --font-body: 'Lato', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-dim);
    font-family: var(--font-body);
    overflow: hidden;
    /* For Locomotive Scroll */
    min-height: 100vh;
}

h1,
h2,
h3,
.medieval-font {
    font-family: var(--font-heading);
    color: var(--text-gold);
    font-weight: 700;
}

/* Utilities */
.hidden {
    display: none !important;
}

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

.modal-content {
    background: #1a1a1a;
    padding: 3rem;
    border: 2px solid var(--border-gold);
    box-shadow: 0 0 30px var(--accent-glow);
    text-align: center;
    max-width: 500px;
    width: 90%;
    position: relative;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: -5px;
    bottom: -5px;
    left: -5px;
    right: -5px;
    border: 1px solid rgba(212, 175, 55, 0.5);
    pointer-events: none;
}

.modal-title {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.modal-subtitle {
    font-style: italic;
    margin-bottom: 2rem;
    color: var(--text-dim);
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-gold);
    font-family: var(--font-heading);
    font-size: 1.1rem;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.8rem;
    background: #0f0f0f;
    border: 1px solid var(--border-dark);
    color: var(--parchment);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--border-gold);
}

/* Medieval Button */
.medieval-btn {
    background: transparent;
    border: 2px solid var(--border-gold);
    color: var(--text-gold);
    padding: 1rem 2rem;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    margin-top: 1rem;
}

.medieval-btn:hover {
    background: var(--border-gold);
    color: var(--bg-dark);
    box-shadow: 0 0 20px var(--accent-glow);
}

/* Game Layout */
.game-container {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
}

.game-header {
    text-align: center;
    margin-bottom: 4rem;
    /* Spacing for scroll effect */
    padding-top: 2rem;
}

.game-title {
    font-size: 4rem;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    letter-spacing: 3px;
}

.game-subtitle {
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.game-layout {
    display: flex;
    gap: 2rem;
    height: 70vh;
    /* Fixed height for inner scrolling areas if needed, or flex */
    align-items: flex-start;
}

/* Narrative Section */
.narrative-section {
    flex: 2;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.parchment-bg {
    background-color: var(--parchment);
    color: #2c2c2c;
    padding: 2rem;
    border-radius: 4px;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.2), 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* Chat Log styling */
.chat-log {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    padding-right: 1rem;
    max-height: 500px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.chat-message {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.message-role {
    font-weight: bold;
    font-family: var(--font-heading);
    margin-bottom: 0.2rem;
    display: block;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.role-dm {
    color: #8b0000;
}

.role-player {
    color: #00008b;
}

.input-area {
    display: flex;
    gap: 1rem;
    position: relative;
    align-items: center;
}

#player-input {
    flex-grow: 1;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid #5c5c5c;
    font-family: var(--font-body);
    font-size: 1rem;
    color: #1a1a1a;
}

#player-input:focus {
    outline: none;
    border-color: #8b0000;
    background: rgba(255, 255, 255, 0.8);
}

.medieval-btn-small {
    background: #2c2c2c;
    color: var(--parchment);
    border: none;
    padding: 1rem 1.5rem;
    font-family: var(--font-heading);
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.3s;
}

.medieval-btn-small:hover {
    background: #4a4a4a;
}

#loading-indicator {
    position: absolute;
    bottom: -2rem;
    left: 0;
    font-style: italic;
    color: #2c2c2c;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rune-spinner {
    display: inline-block;
    animation: spin 2s infinite linear;
    color: #8b0000;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Sidebar Section */
.sidebar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.medieval-panel {
    border: 1px solid var(--border-dark);
    background: rgba(20, 20, 20, 0.8);
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.medieval-panel h2 {
    border-bottom: 1px solid var(--border-gold);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

.stat-label {
    color: var(--text-dim);
}

.stat-value {
    color: var(--parchment);
    font-weight: bold;
}

/* Inventory Grid */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.inventory-slot {
    aspect-ratio: 1;
    background: #0f0f0f;
    border: 1px solid var(--border-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
    transition: border-color 0.2s;
    cursor: pointer;
    overflow: hidden;
    padding: 2px;
}

.inventory-slot:hover {
    border-color: var(--border-gold);
}

/* Footer */
.game-footer {
    text-align: center;
    margin-top: 4rem;
    color: var(--text-dim);
    font-size: 0.8rem;
    padding-bottom: 2rem;
}

/* Stats & HP */
.hp-container {
    margin-bottom: 1rem;
}

.hp-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.3rem;
    font-weight: bold;
    color: var(--accent-red);
}

.hp-bar-bg {
    width: 100%;
    height: 10px;
    background: #2c2c2c;
    border: 1px solid var(--border-dark);
    border-radius: 5px;
    overflow: hidden;
}

.hp-bar-fill {
    height: 100%;
    background: #8b0000;
    transition: width 0.5s ease;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.stat-box {
    background: #1a1a1a;
    border: 1px solid var(--border-dark);
    padding: 0.5rem;
    text-align: center;
    border-radius: 4px;
}

.stat-name {
    display: block;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 0.2rem;
}

.stat-val {
    font-size: 1.1rem;
    color: var(--parchment);
    font-weight: bold;
}

.divider-gold {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-gold), transparent);
    margin: 1rem 0;
}

/* Equipment */
.equipment-slots {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.equip-slot {
    flex: 1;
    background: #0f0f0f;
    border: 1px solid var(--border-dark);
    aspect-ratio: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
}

.equip-slot:hover {
    border-color: var(--text-gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

.slot-label {
    position: absolute;
    top: -1.2rem;
    left: 0;
    width: 100%;
    font-size: 0.7rem;
    text-align: center;
    color: var(--text-dim);
}

.slot-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.item-icon {
    width: 80%;
    height: 80%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.weapon-stats {
    font-size: 0.9rem;
    text-align: center;
    color: var(--parchment);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem;
    border-radius: 4px;
}

/* Scrollbar styling for chat */
.chat-log::-webkit-scrollbar {
    width: 8px;
}

.chat-log::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.chat-log::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

/* Location Display */
.location-container {
    margin-top: 1rem;
    font-size: 1.2rem;
    color: var(--text-gold);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
}

.location-icon {
    color: var(--accent-red);
    animation: pulse 3s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

/* History Modal */
.modal-wide {
    max-width: 800px;
    width: 95%;
}

.history-log-container {
    height: 400px;
    overflow-y: auto;
    text-align: left;
    padding: 1rem;
    background: #0f0f0f;
    border: 1px solid var(--border-dark);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
}

.history-entry {
    margin-bottom: 1rem;
    border-bottom: 1px solid #333;
    padding-bottom: 0.5rem;
}

.history-role {
    font-weight: bold;
    color: var(--text-gold);
    margin-bottom: 0.2rem;
    display: block;
}

/* Text Highlighting */
.highlight-monster {
    color: #ff4500;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 69, 0, 0.3);
}

.highlight-item {
    color: #ffd700;
    font-weight: bold;
    border-bottom: 1px dashed #ffd700;
}

.highlight-dmg {
    color: #ff3333;
    font-weight: bold;
}

.highlight-action {
    color: #00bfff;
    font-weight: bold;
}

.highlight-char {
    color: #32cd32;
    font-weight: bold;
}

.highlight-location {
    color: var(--accent-red);
    font-weight: bold;
    text-shadow: 0 0 8px rgba(138, 43, 226, 0.6);
    letter-spacing: 0.5px;
}