@font-face {
    font-family: 'klfad';
    src: url('fonts/klfad.woff2') format('woff2'),
         url('fonts/klfad.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}   
@font-face {
	font-family: 'zx-spectrum';
	src: url('fonts/zx-spectrum-webfont.woff2') format('woff2'),
	     url('fonts/zx-spectrum-webfont.woff') format('woff');
	font-weight:normal;
	font-style: normal;
}
@font-face {
  font-family: "Merriweather";
  src: url("/fonts/Merriweather-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; }
}

:root {
    --font-family: 'zx-spectrum', 'Courier New', Courier, monospace;
    --background-color: #000;
    --text-color: #00ff00;
    --info-color: #ffff00;
    --error-color: #ff0000;
    --border-color: #00ff00;
    --link-color: #007bff;
    --button-bg-color: #000;
    --button-text-color: #00ff00;
    --button-border-color: #00ff00;
    --button-hover-bg-color: #00ff00;
    --button-hover-text-color: #000;
}

html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; }

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--font-family);
}

body {
    font-size: 14px;
    text-shadow: 0 0 1px var(--text-color), 0 0 2px rgba(0, 255, 0, 0.5);
    animation: vdu-flicker 15s infinite linear;
}

@keyframes vdu-flicker {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.95;
    }
}

#main-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
}

body, #main-container, #left-column, #right-column {
    transition: background-color 0.5s ease, color 0.5s ease, font-family 0.5s ease;
}

#main-container:fullscreen {
    overflow-y: auto !important;
}


#left-column {
    flex-shrink: 0;
    background-color: var(--background-color);
}

#image-container {
    width: 100%;
    text-align: center;
    padding: 10px 0;
}

#location-image {
    width: 100%;
    max-width: 400px;
    height: auto;
    object-fit: contain;
    display: none;
    margin: 0 auto;
}

#right-column {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 10px;
    min-height: 0;
}

#info-panel {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 10px;
}

#game-stats {
    display: flex;
    justify-content: space-between;
    color: var(--info-color);
    padding-bottom: 5px;
    border-bottom: 1px solid #555;
}
#game-stats p { margin: 0; }

#room-info h2 {
    color: var(--info-color);
    margin: 10px 0 5px 0;
    font-size: 1.2em;
}
#room-info p { margin: 5px 0; }

#history-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#history-container {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 100px;
    scrollbar-width: thin;
    scrollbar-color: var(--text-color) var(--background-color);
}
#history-container::-webkit-scrollbar { width: 8px; }
#history-container::-webkit-scrollbar-track { background: var(--background-color); }
#history-container::-webkit-scrollbar-thumb {
    background-color: var(--text-color);
    border-radius: 4px;
    border: 2px solid var(--background-color);
}

#output p { margin: 0 0 5px 0; }

#input-container {
    display: flex;
    margin-top: 10px;
    flex-shrink: 0;
    cursor: text;
}

#prompt { margin-right: 8px; }

#input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: inherit;
}
#input:focus { outline: none; }

.info { color: var(--info-color); }
.error { color: var(--error-color); }

#start-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--background-color);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 100; padding: 20px;
}
#start-image-container {
    position: relative; width: 100%; max-width: 800px;
    max-height: 85vh; display: flex;
    align-items: center; justify-content: center;
}
#start-button {
    position: absolute; bottom: 10%; left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-family);
    font-size: 20px; 
    color: var(--button-text-color); 
    background-color: var(--button-bg-color);
    border: 2px solid var(--button-border-color); 
    padding: 15px 30px;
    cursor: pointer; text-transform: uppercase;
}
#start-button:hover { 
    background-color: var(--button-hover-bg-color); 
    color: var(--button-hover-text-color); 
}

#music-controls {
    position: fixed; top: 10px; right: 10px; z-index: 50;
}
/* Music note icon with optional diagonal strikethrough when muted */
.music-icon {
    position: relative;
    display: inline-block;
    font-style: normal;
}
#music-toggle.music-off .music-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -2px;
    right: -2px;
    height: 2px;
    background: currentColor;
    transform: rotate(-45deg) translateY(-50%);
    pointer-events: none;
}
#music-toggle, #fullscreen-toggle, #logout-button, #map-toggle, #help-button, #boss-button, #guest-register-btn {
    font-family: var(--font-family);
    font-size: 12px; 
    color: var(--button-text-color); 
    background-color: var(--button-bg-color);
    border: 1px solid var(--button-border-color); 
    padding: 5px 10px; 
    cursor: pointer;
    margin-left: 10px;
    text-decoration: none;
}
#map-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #0a0a0a;
    z-index: 1000;
    flex-direction: column;
}
#map-close {
    position: absolute;
    top: 10px; right: 10px;
    z-index: 10;
    font-family: var(--font-family);
    font-size: 12px;
    color: var(--button-text-color);
    background-color: var(--button-bg-color);
    border: 1px solid var(--button-border-color);
    padding: 5px 10px;
    cursor: pointer;
}
#map-svg-container {
    position: relative;
    flex: 1;
    overflow: hidden;
}

#volume-slider {
    width: 70px;
    vertical-align: middle;
    margin-left: 10px;
    cursor: pointer;
    accent-color: var(--button-bg-color);
}

#game-overlay-logo {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 200;
    pointer-events: none;
}

#game-overlay-logo.fade-in-out img {
    max-width: 75px;
    max-height: 75px;
    animation: fadeInOut 10s forwards;
}

.hidden { display: none; }

/* Desktop layout */
@media (min-width: 768px) {
    body {
        font-size: 15px;
        overflow: hidden; /* Prevent body scroll on desktop */
    }
    #main-container {
        flex-direction: row;
        height: 100vh;
    }
    #left-column {
        width: 35%;
        height: 100%;
        align-items: center;
        justify-content: center;
    }
    #location-image {
        max-width: 100%;
        max-height: 100%;
        padding: 20px;
    }
    #right-column {
        width: 65%;
        height: 100%;
        padding: 20px;
    }
    #start-button { font-size: 28px; padding: 20px 40px; }
    #music-toggle, #fullscreen-toggle { font-size: 14px; }
    #game-overlay-logo.fade-in-out img {
        max-width: 150px;
        max-height: 150px;
    }
}

/* --- Loader Styles --- */
#loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #008B8B; /* Border color */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

#play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    cursor: pointer;
}

#screen {
    width: 85vw;
    height: 85vh;
    background-color: #EFEFEF; 
    color: #222222; 
    border: none;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    position: relative;
    display: flex;
    flex-direction: column; /* Arrange children vertically */
    justify-content: space-between; /* Pushes children to top and bottom */
    align-items: center; /* Center contents horizontally */
    padding: 25px;
    box-sizing: border-box;
    overflow: hidden;
    z-index: 10;
}

/* Loader top/bottom grouping; user manual link must sit above overlay */
.loader-top,
.loader-bottom {
    /* ensure loader sections span full width so text-lines align left */
    width: 100%;
    align-self: stretch;
}
.loader-link a {
    position: relative;
    z-index: 10001;
    text-decoration: none;
}

#loading-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    z-index: 1;
}

.loading-bar {
    width: 100%;
    animation-duration: 0.2s;
    animation-timing-function: steps(2, end);
    animation-iteration-count: infinite;
}

@keyframes load-anim {
    0% { background-color: #4169E1; } /* Royal Blue */
    50% { background-color: #B5A642; } /* Dirty Yellow */
}

.text-line {
    font-size: 1.25vw;
    text-align: left;
    text-transform: uppercase;
    text-shadow: 0 0 1px rgba(0,0,0,0.4);
    width: 100%; /* Ensure it takes full width for alignment */
}

#loading-text-glitch {
    display: none; /* Hidden by default */
    position: absolute;
    top: 25px;
    left: 25px;
}

#copyright {
    text-transform: none; /* Override uppercase style */
}

#cursor {
    display: inline-block;
    width: 1.25vw;
    height: 1.5vw;
    background-color: #222222;
    animation: blink 1s step-end infinite;
    margin-left: 5px;
    vertical-align: bottom;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Media query for smaller screens */
@media (max-width: 768px) {
    .text-line {
        font-size: 2.5vw;
    }
    #cursor {
        width: 2.5vw;
        height: 3vw;
    }
    #music-controls {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 4px;
        top: 6px;
        right: 6px;
        max-width: calc(100vw - 12px);
    }
    #music-toggle, #fullscreen-toggle, #logout-button, #map-toggle, #help-button, #boss-button,
    #guest-register-btn, #guest-timer {
        font-size: 10px;
        padding: 4px 7px;
        margin-left: 0;
    }
    #volume-slider {
        order: 10;
        width: 100%;
        margin-left: 0;
    }
    /* Bounded height so the history panel scrolls within the viewport */
    #main-container {
        height: calc(var(--vh, 1vh) * 100);
        min-height: unset;
        overflow: hidden;
    }
    /* Cap the image column so it doesn't crowd out the text */
    #left-column {
        max-height: 35vh;
        max-height: calc(var(--vh, 1vh) * 35);
        overflow: hidden;
        flex-shrink: 0;
    }
    #location-image { max-height: 34vh; max-height: calc(var(--vh, 1vh) * 34); }
    /* Send button — visible on mobile only */
    #send-button {
        display: flex;
        align-items: center;
        font-family: var(--font-family);
        font-size: inherit;
        color: var(--button-text-color);
        background-color: var(--button-bg-color);
        border: 1px solid var(--button-border-color);
        border-left: none;
        padding: 0 10px;
        cursor: pointer;
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* Boss overlay: reset all game styles so it looks like a real Word document */
#boss-overlay,
#boss-overlay * {
    text-shadow: none !important;
    animation: none !important;
    font-family: Calibri, Arial, Helvetica, sans-serif;
    color: #111;
    background-color: transparent;
    border-color: initial;
    box-shadow: none;
}
#boss-overlay {
    background-color: #f2f2f2 !important;
    color: #111 !important;
}
#boss-titlebar {
    background-color: #2b579a !important;
    color: #fff !important;
}
#boss-titlebar * { color: #fff !important; }
#boss-ribbon {
    background-color: #fff !important;
    border-bottom: 1px solid #c8c8c8 !important;
}
#boss-doc > div {
    background-color: #fff !important;
    box-shadow: 0 0 10px rgba(0,0,0,0.12) !important;
}
#boss-ruler { background-color: #e8e8e8 !important; color: #888 !important; }

/* --- Drawing Canvas Styles --- */
#drawing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    display: none; /* Hidden by default */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#canvas-container {
    display: grid;
    place-items: center;
}

#canvas-container > * {
    grid-area: 1 / 1;
}

/* Mobile: stack tools above canvas with minimal gap */
@media (max-width: 767px) {
    #drawing-tools {
        margin-bottom: 10px;
        padding: 2px;
        gap: 3px;
    }
    #drawing-tools button {
        padding: 5px;
        font-size: 10px;
    }
    #drawing-tools button.color-button {
        width: 18px;
        height: 18px;
    }
}

#drawing-canvas {
    border: 2px solid var(--button-border-color);
    cursor: crosshair;
}

#drawing-tools {
    background: var(--background-color);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid var(--button-border-color);
    display: flex;
    gap: 10px;
    margin-bottom: 20px; /* Space between palette and canvas */
}

#drawing-tools button {
    padding: 10px;
    font-family: var(--font-family);
    font-size: 16px;
    cursor: pointer;
    background-color: var(--button-bg-color);
    color: var(--button-text-color);
    border: 1px solid var(--button-border-color);
}

#drawing-tools button:hover {
    background-color: var(--button-hover-bg-color);
    color: var(--button-hover-text-color);
}

/* Color swatch buttons for drawing tools */
#drawing-tools button.color-button {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid var(--button-border-color);
    background-color: transparent;
    color: transparent;
}

#drawing-tools #color-black { background-color: #000; }
#drawing-tools #color-white { background-color: #fff; }
#drawing-tools #color-red   { background-color: #f00; }
#drawing-tools #color-green { background-color: #0f0; }
#drawing-tools #color-blue  { background-color: #00f; }
#drawing-tools #color-yellow { background-color: #ff0; }

#drawing-tools button.color-button:hover {
    opacity: 0.7;
}

/* Clickable buttons styled like command buttons */
.exit-button {
    margin-right: 0.5em;
    padding: 0.2em 0.5em;
    background-color: var(--button-bg-color);
    color: var(--button-text-color);
    border: 1px solid var(--button-border-color);
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--font-family);
    text-transform: capitalize;
}
.exit-button:hover {
    background-color: var(--button-hover-bg-color);
    color: var(--button-hover-text-color);
}

/* Dialogue choice buttons use exit-button styling */
.dlg-button {
    margin-right: 0.5em;
    padding: 0.2em 0.5em;
    background-color: var(--button-bg-color);
    color: var(--button-text-color);
    border: 1px solid var(--button-border-color);
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--font-family);
    text-transform: capitalize;
}
.dlg-button:hover {
    background-color: var(--button-hover-bg-color);
    color: var(--button-hover-text-color);
}

/* Clickable buttons for inventory items in CYAN */
#room-inventory {
    margin-top: 5px;
}
/* Inherited exit-button styles apply here */
#room-inventory .inventory-button {
    margin-right: 0.5em;
    padding: 0.2em 0.5em;
    background-color: #000;
    color: #00ffff;
    border: 1px solid #00ffff;
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--font-family);
    text-transform: capitalize;
}
#room-inventory .inventory-button:hover {
    opacity: 0.7;
}

/* Label for inventory section */
#room-inventory .inventory-label {
    color: #00ffff;
    font-weight: bold;
    margin-right: 0.5em;
}

/* Clickable buttons for room items (You see:) in yellow */
#room-items {
    margin-top: 5px;
}
/* Inherited exit-button styles apply here */
#room-items .item-button {
    margin-right: 0.5em;
    padding: 0.2em 0.5em;
    background-color: #000;
    color: #ffff00;
    border: 1px solid #ffff00;
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--font-family);
    text-transform: capitalize;
}
#room-items .item-button:hover {
    opacity: 0.7;
}
/* Label for room items */
#room-items .item-label {
    color: #ffff00;
    font-weight: bold;
    margin-right: 0.5em;
}

/* Clickable buttons for NPCs in magenta */
#room-items .npc-label {
    color: #ff00ff;
    font-weight: bold;
    margin-right: 0.5em;
}
#room-items .npc-button {
    margin-right: 0.5em;
    padding: 0.2em 0.5em;
    background-color: #000;
    color: #ff00ff;
    border: 1px solid #ff00ff;
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--font-family);
    text-transform: capitalize;
}
#room-items .npc-button:hover {
    opacity: 0.7;
}

/* Dialogue option buttons */
.dialogue-option {
    margin-right: 0.5em;
    padding: 0.2em 0.5em;
    background-color: #000;
    color: #ff00ff;
    border: 1px solid #ff00ff;
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--font-family);
    text-transform: capitalize;
}
.dialogue-option:hover {
    opacity: 0.7;
}
