*::before,
*::after {
  box-sizing: border-box;
}

/* Custom Fonts */
@font-face {
  font-family: 'SpecialElite';
  src: url('fonts/SpecialElite.woff2') format('woff2'),
       url('fonts/SpecialElite.woff') format('woff'),
       url('fonts/SpecialElite.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700&display=swap');

/* Root Variables */
:root {
  /* Colors */
  --color-primary: #c51077;
  --color-secondary: #6c2a6c;
  --color-accent: #ffcc00;
  --color-background-medium: #1a1a2e;
  --color-background-light: #2a2a3e;
  --color-text-light: #e0e0e0;
  --color-text-dark: #1a1a2e;
  --color-border: #555;
   --color-background-dark: #1a001a; /* Very dark purple/black */
    --color-accent-glow: #8a2be2; /* Blue-violet for the glow, adjust as desired */
    --color-primary-button: #4b0082; /* Indigo for button background */
    --color-secondary-button-hover: #6a0dad; /* Darker purple for button hover */

  /* Typography */
  --font-main: 'SpecialElite', serif;
  --font-decorative: 'Cinzel Decorative', serif;

  /* Spacing */
  --padding-small: 10px;
  --padding-medium: 20px;
  --margin-small: 10px;
  --margin-medium: 20px;

  /* Border Radius */
  --border-radius: 8px;

  /* Box Shadow */
  --box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: var(--font-main);
    background-color: var(--color-background-dark);
    color: var(--color-text-light);
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    background: radial-gradient(ellipse at center, #0d0d0d 0%, #000000 100%);
    backdrop-filter: blur(6px);
    text-align: center;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

/* Flickering title effect */
#opening-screen h1 {
    font-family: 'Creepster', var(--font-eerie, cursive);
    color: #f8f8f8;
    font-size: 5em;
    margin-bottom: 25px;
    text-shadow: 
        0 0 5px #b30000,
        0 0 15px #ff1a1a,
        0 0 30px #ff1a1a;
    animation: flicker 3s infinite;
}

/* Ghostly subtitle */
#opening-screen p {
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.65);
    margin-bottom: 20px;
    font-family: 'Lora', serif;
    font-style: italic;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

.yellow-line {
    color: #ffcc00;
    text-shadow: 0 0 5px #ffcc00;
}

/* Eerie glowing button */
#start-game-button {
    padding: 14px 32px;
    font-size: 1.5em;
    background-color: #1a1a1a;
    color: #ffffff;
    border: 2px solid #b30000;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 40px;
    box-shadow: 0 0 10px #b30000;
    transition: all 0.3s ease-in-out;
    font-family: 'Cinzel', serif;
    letter-spacing: 1px;
}

#start-game-button:hover {
    background-color: #330000;
    transform: scale(1.05);
    box-shadow: 0 0 20px #ff1a1a, 0 0 30px #990000;
}

/* Keyframe animations */
@keyframes flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        opacity: 1;
        text-shadow: 0 0 5px #b30000, 0 0 15px #ff1a1a, 0 0 30px #ff1a1a;
    }
    20%, 24%, 55% {
        opacity: 0.8;
        text-shadow: none;
    }
}

/* Keyframe animation for pulsating glow */
@keyframes pulse-glow {
    from {
        text-shadow: 0 0 10px var(--color-accent-glow), 0 0 20px var(--color-accent-glow);
    }
    to {
        text-shadow: 0 0 20px var(--color-accent-glow), 0 0 30px var(--color-accent-glow), 0 0 40px var(--color-accent-glow);
    }
}

/* --- Game Container Layout - Main Grid --- */
#game-container {
    display: flex;
    flex-direction: column;
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr;
    grid-template-areas:
        "top-bar"
        "main-content";
    height: auto;
    width: 100vw;
    box-sizing: border-box;
    padding: var(--padding-small);
    background-color: var(--color-background-dark);
    gap: var(--padding-small);
}

/* Mute button is now absolutely positioned within the scene */
#mute-button {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background-color: var(--color-secondary);
    color: var(--color-text-light);
    border: none;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    z-index: 60;
    font-family: var(--font-main);
    font-size: 0.9em;
}

#mute-button:hover {
    background-color: var(--color-primary);
}


#top-bar {
    grid-area: top-bar;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--padding-small) var(--padding-medium);
    background-color: var(--color-background-medium);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

#top-bar h2 {
    margin: 0;
    color: var(--color-accent);
    display: none; /* Hidden as it's an overlay now */
}

#room-select {
    padding: 8px;
    border-radius: var(--border-radius);
    background-color: var(--color-background-light);
    color: var(--color-text-light);
    border: 1px solid var(--color-border);
    font-family: var(--font-main);
}

#lock-code-display {
    font-size: 1.2em;
    color: var(--color-text-light);
}

#current-lock-code {
    color: var(--color-accent);
    font-weight: bold;
}

/* --- Main Content Grid: Scene and Right Panel --- */
#main-content-grid {
    grid-area: main-content;
    display: flex;
    flex-direction: column;
    grid-template-columns: 4fr 1fr;
    gap: var(--padding-medium);
    height: auto;
    min-height: 0;
}

#scene {
    position: relative;
    background-size: cover;
    background-position: center;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

/* Scene Name Overlay */
#scene-name-overlay {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: var(--color-accent);
    padding: 5px 10px;
    border-radius: var(--border-radius);
    font-size: 1.2em;
    font-family: var(--font-decorative);
    text-shadow: 0 0 10px var(--color-accent);
    z-index: 55;
    white-space: nowrap;
    pointer-events: none;
}


#right-panel {
    overflow-y: visible; /* Allow overflow for chat and inventory */
    max-height: none;
    display: flex;
    flex-direction: column;
    background-color: var(--color-background-medium);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: var(--padding-small);
    gap: var(--padding-small);
    min-height: 0;
}

/* --- Chat Window (now inside right-panel) --- */
#chat-container {
    display: flex;
    flex-direction: column; /* Stack elements vertically in their natural order */
    background-color: var(--color-background-light);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
    height: 100%; /* Full height of the right panel */
    min-height: 250px; /* Minimum height to prevent collapse */
    padding: 10px; /* Padding inside the chat container */
    margin-bottom: 10px; /* Space between chat and inventory */
    /* Use flex-grow for chat-container to take available space */
    flex-grow: 1; /* Allow it to grow and push inventory down if needed */
}

#chat-input-area {
    display: flex;
    padding: var(--padding-small);
    background-color: var(--color-background-light);
    border-bottom: 1px solid var(--color-border); /* Border at the bottom of input area */
    gap: var(--padding-small);
    flex-shrink: 0; /* Prevent from shrinking */
    order: 1; /* Place input area first in the flex column */
}
#chat-input-area input,
#chat-input-area button {
  font-size: 1em;
  height: auto;
}

#chat-output {
    height: 100px; /* Approximate height for 3 lines of text. Adjust as needed. */
    overflow-y: auto; /* Enable scrolling for messages */
    padding: var(--padding-small);
    /* Removed border-bottom as it's now on chat-input-area */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--color-secondary) var(--color-background-dark); /* Firefox */
    display: flex; /* To allow messages to align within */
    flex-direction: column; /* Stack messages */
    flex-shrink: 0; /* Prevent from shrinking */
    order: 2; /* Place chat output second */
    padding-bottom: env(safe-area-inset-bottom);
}


/* Custom scrollbar for Webkit browsers (Chrome, Safari) */
#chat-output::-webkit-scrollbar {
    width: 8px;
}

#chat-output::-webkit-scrollbar-track {
    background: var(--color-background-dark);
    border-radius: var(--border-radius);
}

#chat-output::-webkit-scrollbar-thumb {
    background-color: var(--color-secondary);
    border-radius: var(--border-radius);
    border: 2px solid var(--color-background-dark);
}

.message {
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 15px;
    max-width: 90%;
    line-height: 1.4;
    word-wrap: break-word;
}

.user-message {
    background-color: var(--color-primary);
    color: var(--color-text-light);
    align-self: flex-end;
    margin-left: auto;
}

.bot-message {
    background-color: var(--color-secondary);
    color: var(--color-text-light);
    align-self: flex-start;
    margin-right: auto;
}


#character-select {
    padding: var(--padding-small);
    border-radius: var(--border-radius);
    background-color: var(--color-background-dark);
    color: var(--color-text-light);
    border: 1px solid var(--color-border);
    font-family: var(--font-main);
    flex-shrink: 0;
}

#chat-input {
    flex-grow: 1;
    padding: var(--padding-small);
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    background-color: var(--color-background-dark);
    color: var(--color-text-light);
    font-family: var(--font-main);
    font-size: 1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#chat-input::placeholder {
    color: #888;
}

#chat-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 8px rgba(255, 204, 0, 0.6);
    outline: none;
}

#send-chat-button {
    padding: var(--padding-small) 15px;
    background-color: var(--color-secondary);
    color: var(--color-text-light);
    border: 2px solid var(--color-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 1em;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
    flex-shrink: 0;
}

#send-chat-button:hover {
    background-color: var(--color-primary);
    border-color: var(--color-accent);
    transform: translateY(-2px);
}

/* --- Inventory Section (now inside right-panel) --- */
#room-items-section {
    flex-shrink: 0; /* Prevent from shrinking into chat */
    min-height: 100px; /* Adjust as needed */
}

#collected-inventory-container {
    flex-shrink: 0; /* Prevent from shrinking into chat */
    min-height: 100px; /* Adjust as needed */
}

#inventory-bar, #collected-inventory-container h3 {
    background-color: var(--color-background-light);
    padding: var(--padding-small);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    flex-shrink: 0; /* Prevent titles from shrinking */
}

#inventory-bar h3, #collected-inventory-container h3 {
    color: var(--color-accent);
    margin-top: 0;
    margin-bottom: var(--margin-small);
    text-align: center;
}

#room-items-grid, #collected-inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    padding: 5px;
    min-height: 80px; /* Adjusted to prevent collapse */
    max-height: 150px; /* Stays fixed, adjust as desired */
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background-color: var(--color-background-dark);
}


.inventory-box {
    background-color: var(--color-background-medium);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    text-align: center;
    font-size: 0.7em;
    color: var(--color-text-light);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 60px;
}

.inventory-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 10px var(--color-accent);
}

.inventory-box img {
    max-width: 90%;
    max-height: 40px;
    object-fit: contain;
    margin-bottom: 3px;
}

/* --- Legend (now inside right-panel, at bottom) --- */
#legend-box {
    background-color: var(--color-background-light);
    padding: var(--padding-small);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    flex-shrink: 0; /* Prevent it from shrinking */
}


/* --- Dialogue Box --- */
.dialogue {
    position: absolute;
    bottom: 20px;
    left: 40%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    padding: var(--padding-medium);
    border-radius: var(--border-radius);
    max-width: 70%;
    text-align: left;
    z-index: 50;
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dialogue-img {
    width: 100px;
    height: 100px;
    border-radius: 40%;
    object-fit: cover;
    margin-bottom: var(--margin-small);
    border: 2px solid var(--color-accent);
}

.dialogue span {
    font-size: 1.5em;
    line-height: 1;
}

/* --- Game Popup (for "You collected..." messages) --- */
#game-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: var(--color-accent);
    padding: var(--padding-medium);
    border-radius: var(--border-radius);
    text-align: center;
    font-size: 1.3em;
    font-weight: bold;
    z-index: 100;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.8);
}

/* --- Item Enlargement Modal --- */
#item-enlarge-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    cursor: pointer;
    padding: var(--padding-medium);
    box-sizing: border-box;
}

#item-enlarge-modal.hidden {
    display: none;
}

#enlarged-item-image {
    max-width: 70%;
    max-height: 60%;
    object-fit: contain;
    border: 3px solid var(--color-accent);
    border-radius: var(--border-radius);
    margin-bottom: var(--margin-medium);
    cursor: default;
}

#enlarged-item-description {
    max-width: 60%;
    background-color: var(--color-background-light);
    padding: var(--padding-medium);
    border-radius: var(--border-radius);
    color: var(--color-text-light);
    text-align: center;
    font-size: 1.1em;
    line-height: 1.5;
    cursor: default;
}


/* Guess Murderer Popup (re-used popup-style) */
#guess-murderer {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: var(--padding-medium) 30px;
    border-radius: var(--border-radius);
    text-align: center;
    z-index: 2000;
    box-shadow: 0 0 15px var(--color-accent);
    display: none;
    flex-direction: column;
    gap: var(--margin-small);
    max-width: 400px;
}

#guess-murderer h2 {
    color: var(--color-accent);
    margin-bottom: var(--margin-small);
}

#murderer-select {
    padding: 10px;
    border-radius: var(--border-radius);
    background-color: var(--color-background-dark);
    color: var(--color-text-light);
    border: 1px solid var(--color-border);
    font-family: var(--font-main);
    margin-bottom: var(--margin-small);
}

#guess-murderer button {
    padding: 10px 20px;
    background-color: var(--color-primary);
    color: var(--color-text-light);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 1.1em;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#guess-murderer button:hover {
    background-color: var(--color-secondary);
    transform: scale(1.05);
}

/* Responsive adjustments for smaller screens (optional, but good practice) */
@media (max-width: 768px) {
    #main-content-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 2fr 1.5fr;
    }

    #right-panel {
        max-width: 100%;
        height: auto;
    }

    #scene {
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    #top-bar {
        flex-direction: column;
        gap: 10px;
    }

    #chat-input-area {
        flex-direction: column;
        gap: 10px;
    }

    #character-select, #chat-input, #send-chat-button {
        width: 100%;
    }

    #room-select {
        margin-top: 10px;
    }

    #room-items-grid, #collected-inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }

    .inventory-box {
        min-height: 50px;
    }
    .inventory-box img {
        max-height: 30px;
    }
}
/* Main game styles */
body {
    font-family: 'Courier New', monospace;
    /* ... other styles ... */
}

/* Sliding puzzle styles */
#puzzle-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#puzzle-container {
    background-color: #f0f0f0;
    padding: 20px;
    border: 2px solid #333;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    width: 600px; /* Adjust the size of the container as needed */
    height: 600px;
    display: flex;
    flex-direction: column;
}

#sliding-puzzle-iframe {
    flex-grow: 1; /* Makes the iframe fill the available space */
}

#puzzle-overlay.hidden {
    display: none;
}

#close-puzzle-button {
    margin-top: 10px;
}
@media screen and (max-width: 768px) {
  #game-footer {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
  }
}
    /* Adjustments for the overall layout */
    #main-content-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto; /* top-bar, scene, right-panel */
        gap: var(--padding-small);
    }
    
    #top-bar {
        flex-direction: column;
        gap: var(--padding-small);
        padding: var(--padding-small);
    }

    /* Change the order of the right panel and scene for better mobile flow */
    #scene {
        order: 1; /* Place the scene first */
        min-height: 400px;
    }

    #right-panel {
        order: 2; /* Place the right panel below the scene */
        max-width: 100%;
        height: auto;
        /* Make chat and inventory scrollable within the panel */
        overflow-y: auto;
        padding: var(--padding-small);
    }

    /* Adjust chat input area for better mobile keyboard use */
    #chat-input-area {
        flex-direction: column;
        gap: var(--padding-small);
        padding: var(--padding-small);
    }

    #character-select, #chat-input, #send-chat-button {
        width: 100%;
    }

    #room-select {
        margin-top: var(--margin-small);
    }

    /* Make inventory grids more compact */
    #room-items-grid, #collected-inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 8px;
    }

    .inventory-box {
        min-height: 50px;
    }
    
    .inventory-box img {
        max-height: 30px;
    }
    
    /* Adjust dialogue box positioning for mobile */
    .dialogue {
        left: 50%;
        bottom: 5px;
        transform: translateX(-50%);
        max-width: 90%;
        padding: var(--padding-small);
        font-size: 1em;
    }

    /* Hide the room-select dropdown on mobile since it's redundant with the chat */
    #room-select {
        display: none;
    }
}@media (max-width: 768px) {
  html, body {
    overflow-y: auto;
    height: auto;
    width: 100%;
  }

  #game-container {
    display: flex;
    flex-direction: column;
    height: auto;
    width: 100%;
    overflow-y: auto;
  }

  #main-content-grid {
    display: flex;
    flex-direction: column;
    height: auto;
    gap: var(--padding-small);
    width: 100%;
  }

  #top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  #scene {
    order: 1;
    width: 100%;
    min-height: 300px;
  }

  #right-panel {
    order: 2;
    width: 100%;
    padding: var(--padding-small);
    overflow-y: visible;
  }

  #chat-container {
    height: auto;
    max-height: none;
    flex-grow: 1;
  }

  #chat-output {
    max-height: 150px;
    overflow-y: auto;
  }

  #chat-input-area {
    flex-direction: column;
    gap: 10px;
    padding-bottom: env(safe-area-inset-bottom); /* For phones with notches */
  }

  #character-select, #chat-input, #send-chat-button {
    width: 100%;
  }

  #room-items-grid,
  #collected-inventory-grid {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  }

  .dialogue {
    bottom: 5px;
    max-width: 95%;
    font-size: 1em;
    padding: 10px;
    left: 50%;
    transform: translateX(-50%);
  }

  #item-enlarge-modal {
    padding: 10px;
  }

  #enlarged-item-description {
    max-width: 90%;
  }

  #puzzle-container {
    width: 90vw;
    height: 90vw;
  }
}
