/* CSS Variables for theming */
:root {
    --bg-color: #000;
    --text-color: #33ff33;
    --border-color: #33ff33;
    --highlight-color: #66ff66;
    --dim-color: #1a661a;
    --enemy-color: #ff3333;
    --item-color: #ffff33;
    --header-bg: #002200;
    --menu-bg: rgba(0, 20, 0, 0.9);
    --panel-bg: rgba(0, 10, 0, 0.8);
    --font-size-small: 12px;
    --font-size-medium: 16px;
    --font-size-large: 20px;
    --wand-color: #ffff33;
    --potion-color: #33ff33;
    --armor-color: #33ccff;
    --out-of-bounds-color: #0a0a0a;
    --fog-color: #111111;
    --narrator-text-color: #d8d8ff;
    --narrator-shadow: #9090ff;
    --narrator-bg: rgba(5, 5, 15, 0.8);
    --narrator-border: #4040a0;
    --narrator-highlight: #7070e0;
}

/* Dark mode preferred */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000;
        --text-color: #33ff33;
    }
}

/* Light mode */
@media (prefers-color-scheme: light) {
    :root {
        --bg-color: #000;
        --text-color: #33ff33;
    }
}

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

body {
    font-family: 'Courier New', monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 1600px; /* Increased to allow for three panel layout */
    height: 95vh; /* Increased to use more vertical space */
    border: 2px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

/* Screen management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    padding: 10px;
}

.screen.active {
    display: flex;
}

/* Menu Screen */
#menu-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: var(--menu-bg);
}

#menu-screen h1 {
    font-size: 4rem;
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--text-color);
    letter-spacing: 4px;
    background: linear-gradient(45deg, var(--text-color), var(--highlight-color), var(--text-color));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: gradientBG 5s ease infinite;
    text-shadow: none;
}

.menu-options {
    margin-top: 40px;
}

button {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    margin: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

button:hover {
    background-color: var(--dim-color);
    color: var(--highlight-color);
}

/* Game Screen */
#game-screen {
    background-color: var(--bg-color);
    flex-direction: row; /* Change to row layout */
    padding: 0;
    overflow: hidden; /* Prevent content from overflowing */
}

/* Game Main (left panel) */
#game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-right: 1px solid var(--border-color);
    min-width: 0; /* Allow flex container to shrink below content size */
    overflow: hidden; /* Prevent content from overflowing */
}

#game-header {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
}

#game-display-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background-color: var(--panel-bg);
    cursor: grab; /* Indicate the area is draggable */
}

#game-display {
    font-family: 'Courier New', monospace;
    white-space: pre;
    overflow: hidden;
    line-height: 1.1;
    padding: 10px;
    height: calc(100% - 20px);
    box-sizing: border-box;
    user-select: none; /* Prevent text selection while dragging */
}

/* Narrator Panel (middle) */
#narrator-panel {
    width: 400px; /* Fixed width */
    min-width: 350px; /* Ensure minimum width */
    max-width: 450px; /* Ensure maximum width */
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--narrator-bg);
    border-right: 1px solid var(--narrator-border);
    overflow: hidden;
}

#narrator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--narrator-border);
}

.panel-title {
    font-weight: bold;
    color: var(--narrator-highlight);
}

.panel-controls {
    display: flex;
    gap: 5px;
}

.panel-btn {
    background-color: transparent;
    color: var(--narrator-text-color);
    border: 1px solid var(--narrator-border);
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.panel-btn:hover {
    background-color: rgba(64, 64, 160, 0.3);
    color: var(--narrator-highlight);
}

#narrator-current {
    padding: 15px;
    font-size: 16px;
    border-bottom: 1px solid var(--narrator-border);
    min-height: 140px;
    max-height: 140px;
    overflow-y: auto;
    line-height: 1.4;
    color: var(--narrator-text-color);
    font-style: italic;
    text-shadow: 0 0 2px var(--narrator-shadow);
    transition: opacity 0.5s;
}

#narrator-history-container {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
}

#narrator-history {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px;
}

.narrative-entry {
    padding: 10px;
    border-radius: 4px;
    background-color: rgba(20, 20, 40, 0.3);
    color: var(--narrator-text-color);
    font-style: italic;
    border-left: 3px solid var(--narrator-border);
    font-size: 14px;
    line-height: 1.4;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.narrative-entry:hover {
    opacity: 1;
    border-left-color: var(--narrator-highlight);
}

.narrative-timestamp {
    font-size: 11px;
    color: rgba(160, 160, 220, 0.6);
    margin-top: 5px;
    text-align: right;
}

/* Right panel (message log and controls) */
#game-right-panel {
    width: 280px; /* Reduced width since we now have three panels */
    min-width: 250px; /* Ensure minimum width */
    max-width: 300px; /* Ensure maximum width */
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--panel-bg);
}

#panel-header {
    padding: 5px 10px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    font-weight: bold;
}

#narrator-section {
    padding: 10px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    min-height: 120px;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.4;
    color: #d8d8ff;
    font-style: italic;
    text-shadow: 0 0 2px #9090ff;
    transition: opacity 1s ease;
}

#message-log {
    flex: 2;
    overflow-y: auto;
    padding: 5px 10px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

.message-combat {
    color: var(--enemy-color);
    border-left: 2px solid var(--enemy-color);
    padding-left: 5px;
    margin-bottom: 3px;
}

.message-item {
    color: var(--item-color);
    border-left: 2px solid var(--item-color);
    padding-left: 5px;
    margin-bottom: 3px;
}

#game-controls {
    padding: 10px;
}

.control-group {
    margin-bottom: 15px;
}

.control-group h4 {
    margin-bottom: 5px;
    border-bottom: 1px solid var(--dim-color);
    padding-bottom: 3px;
}

.control-buttons {
    display: flex;
    justify-content: center;
}

.zoom-btn {
    background-color: var(--button-bg);
    color: var(--button-text);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 14px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.zoom-btn:hover {
    background-color: var(--button-hover);
}

/* Zoom controls */
#zoom-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 5px;
    padding: 5px;
    z-index: 100;
}

/* Instructions Screen */
#instructions-screen {
    padding: 20px;
    overflow-y: auto;
    background-color: var(--menu-bg);
}

.instructions-content {
    margin: 20px 0;
}

.instructions-content ul {
    list-style-type: none;
    margin: 10px 0 20px 20px;
}

/* Inventory Screen */
#inventory-screen {
    background-color: var(--menu-bg);
    padding: 20px;
    justify-content: flex-start;
}

#inventory-items {
    flex: 1;
    overflow-y: auto;
    margin: 20px 0;
}

.equipment-summary {
    line-height: 2;
}

/* Custom styling for entities */
.player {
    color: white;
    text-shadow: 0 0 5px white;
}

.enemy {
    color: var(--enemy-color);
    text-shadow: 0 0 4px var(--enemy-color);
}

.item {
    color: var(--item-color);
    text-shadow: 0 0 4px var(--item-color);
}

.wall {
    color: var(--dim-color);
}

.armor {
    color: var(--armor-color);
    text-shadow: 0 0 4px var(--armor-color);
}

.out-of-bounds {
    color: var(--out-of-bounds-color);
}

.fog {
    color: var(--fog-color); 
    opacity: 0.5;
}

/* Add animated fog effect */
@keyframes fogPulse {
    0% { opacity: 0.3; }
    50% { opacity: 0.6; }
    100% { opacity: 0.3; }
}

.fog {
    animation: fogPulse 4s ease-in-out infinite;
}

/* Additional styled controls */
#toggle-fog {
    background-color: var(--panel-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.3s;
    margin: 5px;
    min-width: 120px;
}

#toggle-fog:hover {
    background-color: var(--dim-color);
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
    #game-screen {
        flex-direction: column;
    }

    #game-right-panel {
        max-width: 100%;
        height: 200px;
    }

    #menu-screen h1 {
        font-size: 3rem;
    }
}

@media screen and (max-width: 480px) {
    #menu-screen h1 {
        font-size: 2rem;
    }
    
    button {
        font-size: 1rem;
        padding: 8px 16px;
    }
}

/* Visual Effects */
.particle-effect {
    position: absolute;
    pointer-events: none;
    z-index: 15;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
}

.text-effect {
    position: absolute;
    pointer-events: none;
    z-index: 20;
    font-weight: bold;
    text-shadow: 0 0 5px currentColor;
    white-space: nowrap;
    user-select: none;
}

/* Gradient background for certain elements */
@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Enhanced message styling */
#message-log div {
    transition: all 0.3s ease;
}

#message-log div:last-child {
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
} 