/* --- Modern CSS Reset for Easier Layouts --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #000;
    color: #00FF41;
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px;
}

#game-container {
    /* UPDATED: Set a specific width and max-width */
    width: 800px;
    max-width: 100%; /* Ensure it doesn't overflow on small screens */

    border: 1px solid #00FF41;
    padding: 10px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    
    /* NEW: Auto margins will center this element perfectly */
    margin-left: auto;
    margin-right: auto;
    
    flex-shrink: 0; /* Prevent it from shrinking */
    transition: all 0.4s ease-in-out;
}

#game-output {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 10px;
}

.output-line {
    white-space: pre-wrap; 
}

#game-input-form {
    display: flex;
}

.prompt {
    margin-right: 8px;
}

#game-input {
    background-color: #000;
    color: #00FF41;
    border: none;
    font-family: inherit;
    font-size: inherit;
    flex-grow: 1;
}

#game-input:focus {
    outline: none;
}

#game-status {
    padding: 5px;
    margin-bottom: 10px;
    border-bottom: 1px solid #00FF41;
    display: flex;
    justify-content: space-between;
    white-space: pre;
}

footer {
    display: block;
    text-align: center;
    margin-top: 20px;
    padding: 10px;
}

.home-link {
    color: #00FF41 !important;
    text-decoration: none;
    font-size: 1em;
}

.home-link:hover {
    color: #00FF41 !important;
    text-decoration: underline;
}

/* --- Layout & Sidebar Styles --- */

#main-content-wrapper {
    display: flex;
    /* REMOVED justify-content and max-width to make it full-width */
    align-items: flex-start;
    padding: 20px; /* Give some space from screen edges */
}

#sidebar-original {
    display: none;
    flex-basis: 300px;
    flex-shrink: 0;
    font-family: 'Courier New', Courier, monospace;
    transition: all 0.4s ease-in-out;
    margin-left: 10px; /* Create space between it and the game window */
}

.mode-original #sidebar-original {
    display: block;
}

#sidebar-content {
    border: 1px dashed #00FF41;
    padding: 15px;
    opacity: 0.9;
    height: 100%;
}

#sidebar-original h4 {
    text-transform: uppercase;
    padding-bottom: 1em;
}

#sidebar-original p {
    margin-bottom: 1em;
}

.sidebar-links {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-links a {
    color: #00FF41;
    text-decoration: none;
}

.sidebar-links a:hover {
    text-decoration: underline;
}

.sidebar-links .download-link {
    font-weight: bold;
    background-color: #004d14;
    padding: 5px 10px;
}

.sidebar-links .download-link:hover {
    background-color: #008a26;
    text-decoration: none;
}

/* --- Collapsible Sidebar Styles --- */

#toggle-sidebar-btn {
    display: block;
    text-align: right;
    color: #00FF41;
    text-decoration: none;
    margin-bottom: 10px;
}

#toggle-sidebar-btn:hover {
    text-decoration: underline;
}

#sidebar-collapsed-handle {
    display: none;
    cursor: pointer;
    padding: 15px;
    border: 1px dashed #00FF41;
    text-align: center;
    white-space: pre;
    font-weight: bold;
    height: 100px;
    width: 90px; /* Give it a specific width to match the image */
}

/* --- THE COLLAPSED STATE --- */

#sidebar-original.sidebar-is-collapsed {
    /* When collapsed, it no longer needs a flex-basis. It will be sized by its content. */
    flex-basis: auto;
    /* We now use margin-left: auto to push it to the far right of the screen! */
    margin-left: 10px;
}

.sidebar-is-collapsed #sidebar-content {
    display: none;
}

.sidebar-is-collapsed #sidebar-collapsed-handle {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* When sidebar is collapsed, the game container should grow */
#sidebar-original.sidebar-is-collapsed ~ #game-container {
    width: 100%; /* Let it grow to fill the available space */
}

/* --- Responsive Styling (Stacking) --- */
@media (max-width: 1200px) {
    #main-content-wrapper {
        flex-direction: column;
        align-items: center;
    }

    #game-container, 
    #sidebar-original {
        /* On mobile, remove the auto margins so they stack normally */
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        max-width: 800px;
    }
    
    #sidebar-original {
        margin-top: 20px;
    }

    #sidebar-original.sidebar-is-collapsed {
        margin-left: 0; /* Must be undone for mobile */
        max-height: 60px;
    }
}

#sidebar-enhanced {
    display: none;
    flex-basis: 300px; /* Give it a consistent width */
    flex-shrink: 0;
    margin-left: 5px; /* Give it the same gutter as the other sidebar */
    
    /* Styling to match the original sidebar */
    border: 1px dashed #00FF41;
    padding: 15px;
    opacity: 0.9;
}

.mode-enhanced #sidebar-enhanced {
    display: block; /* Show the sidebar */
}

#sidebar-enhanced h4 {
    text-transform: uppercase;
    padding-bottom: 1em;
}

/* Add these new sections to the end of your style.css file */

/* --- Feature: Cutscene UI --- */
#cutscene-container {
    display: none; /* Hidden by default, engine makes it visible */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 100;
    color: white;
    font-family: 'Georgia', serif;
}

#cutscene-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0; /* Used for fade transitions */
    transition: opacity 0.5s ease-in-out;
}

#cutscene-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

#cutscene-text-overlay {
    position: absolute;
    bottom: 5%;
    left: 10%;
    right: 10%;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 1.2em;
    text-align: center;
}

#cutscene-skip-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: 1px solid #ccc;
    color: #ccc;
    padding: 8px 16px;
    cursor: pointer;
    z-index: 110;
}
#cutscene-skip-btn:hover {
    background: #fff;
    color: #000;
}

#cutscene-prompt {
    position: absolute;
    bottom: 20px;
    right: 20px;
    color: #aaa;
    font-style: italic;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

/* --- Feature: In-Game Journal UI --- */
#journal-container {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

#journal-modal {
    width: 80%;
    max-width: 900px;
    height: 80vh;
    background-color: #fdf5e6; /* Parchment color */
    color: #3a2a1a; /* Dark brown ink color */
    border: 5px solid #8B4513; /* SaddleBrown border */
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    display: flex;
    font-family: 'Nothing You Could Do', cursive;
    font-size: 18px; /* Slightly larger for legibility */
    position: relative;
}

#journal-left-pane {
    flex-basis: 30%;
    border-right: 2px solid #8B4513;
    display: flex;
    flex-direction: column;
}

#journal-tabs {
    display: flex;
    border-bottom: 2px solid #8B4513;
}

.journal-tab-btn {
    flex-grow: 1;
    padding: 10px;
    background: #e9ddc7;
    border: none;
    cursor: pointer;
    font-size: 1em;
}
.journal-tab-btn.active {
    background: #fdf5e6;
    font-weight: bold;
}

#journal-entry-list {
    list-style: none;
    padding: 10px;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

#journal-entry-list li {
    padding: 8px;
    cursor: pointer;
    border-bottom: 1px dashed #c1b29a;
}
#journal-entry-list li:hover, #journal-entry-list li.active {
    background-color: #e9ddc7;
}

#journal-right-pane {
    flex-basis: 70%;
    padding: 20px;
    overflow-y: auto;
}

#journal-content-display h2 {
    margin-top: 0;
    border-bottom: 1px solid #c1b29a;
    padding-bottom: 10px;
}

/* UPDATED: This rule floats the image to the left */
#journal-content-display img {
    max-width: 40%; /* Reduced a bit more to give text more room */
    height: auto;
    float: left; /* This is the key property */
    
    /* Add space between the image and the wrapping text */
    margin-right: 20px; 
    margin-bottom: 10px;

    border: 1px solid #c1b29a;
}

/* NEW: This is the clearfix to ensure layout stability */
#journal-content-display::after {
    content: "";
    display: table;
    clear: both;
}

#journal-content-display p {
    line-height: 1.6;
}

#journal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #3a2a1a;
}

/* --- Toast Notification UI (Journal Theme) --- */

/* Base style for the notification, themed to match the journal */
#toast-notification {
    /* Positioning from the engine spec */
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000; /* Ensure it's on top of all other UI */

    /* NEW: Styling to match the journal's parchment aesthetic */
    background-color: #fdf5e6; /* Parchment background */
    color: #3a2a1a;           /* Dark brown ink text */
    font-family: 'Georgia', serif;
    border: 3px solid #8B4513; /* Solid, dark brown border */
    padding: 15px 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    
    /* Animation lifecycle hooks from the engine spec */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s, visibility 0.5s, transform 0.5s;
    transform: translateX(-50%) translateY(20px); /* Start slightly lower for a subtle lift effect */
}

/* This class, added by the engine, triggers the fade-in and slide-up animation */
#toast-notification.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0); /* Move to final position */
}

/* This class, added by the engine, triggers the fade-out animation */
#toast-notification.hide {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(20px); /* Move back down on hide */
}

/* Add these new rules to the end of your style.css file */

/* --- Journal Image Interaction --- */
/* Make the thumbnail image appear clickable */
#journal-content-display img {
    /* ... keep all existing styles from the float implementation ... */
    cursor: pointer;
}

/* --- Image Lightbox UI --- */
#image-lightbox-container {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* Dark, semi-transparent overlay */
    z-index: 2000; /* Ensure it's on top of everything, including the journal */
    
    /* Animation hooks */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Class added by JS to trigger the fade-in */
#image-lightbox-container.show {
    display: block;
    opacity: 1;
    visibility: visible;
}

#lightbox-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 90%;
    border: 3px solid #fdf5e6; /* White-ish border */
}

#lightbox-close-btn {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}
#lightbox-close-btn:hover {
    color: #ccc;
}