@font-face {
    font-family: '8bitOperatorPlus-Bold';
    src: url('/fonts/8bitOperatorPlus-Bold.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Deltarune';
    src: url('/fonts/deltarune.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

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

body {
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
}

#game-container {
    position: relative;
    border: 2px solid #333;
    background: #000;
}

#game-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    background: #000;
}

#game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#debug-info {
    position: absolute;
    top: 10px;
    left: 10px;
    color: #fff;
    font-size: 12px;
    text-shadow: 1px 1px 0px #000;
    pointer-events: none;
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
}

#debug-controls {
    margin-top: 10px;
    text-align: center;
}

#debug-controls label {
    color: #fff;
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#debug-checkbox {
    cursor: pointer;
}

#debug-toggle {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 8px 16px;
    cursor: pointer;
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 12px;
    border-radius: 3px;
}

#debug-toggle:hover {
    background: #555;
}

.debug-button {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 8px 16px;
    cursor: pointer;
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 12px;
    border-radius: 3px;
    margin: 5px;
}

.debug-button:hover {
    background: #555;
}

.debug-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#debug-info.hidden {
    display: none;
}

/* Force nearest neighbor filtering for all images */
img {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Fullscreen styles */
#game-container:fullscreen {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    background: #000;
}

#game-container:fullscreen #game-canvas {
    width: min(100vw, calc(100vh * 4/3));
    height: min(100vh, calc(100vw * 3/4));
    max-width: calc(100vh * 4/3);
    max-height: calc(100vw * 3/4);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    margin: auto;
}

/* Webkit fullscreen support */
#game-container:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    background: #000;
}

#game-container:-webkit-full-screen #game-canvas {
    width: min(100vw, calc(100vh * 4/3));
    height: min(100vh, calc(100vw * 3/4));
    max-width: calc(100vh * 4/3);
    max-height: calc(100vw * 3/4);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    margin: auto;
}

/* Initial Loading Screen */
#initial-loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#initial-loading-content {
    text-align: center;
    color: #fff;
}

/* Pre-Game Menu Screen (formerly #loading-screen) */
#pre-game-menu-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#pre-game-menu-content {
    text-align: center;
    color: #fff;
    position: relative; /* For positioning heart cursor absolutely within */
}

#initial-loading-content h1, #pre-game-menu-content h1 {
    font-family: 'Deltarune', '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 32px;
    margin-bottom: 30px;
    letter-spacing: 4px;
    text-shadow: 2px 2px 0px #333;
}

#multiplayer-status-text {
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 18px;
    margin-top: 20px;
    color: #add8e6;
    letter-spacing: 1px;
}

#game-mode-selection, #character-selection {
    display: flex;
    flex-direction: column; /* Stack buttons vertically within selection */
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

#character-selection h2 {
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 24px;
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.character-buttons {
    display: flex;
    justify-content: center;
    gap: 30px; /* Space between Kris and Susie buttons */
    margin-bottom: 20px;
}

.character-select-button {
    background: black;
    color: white;
    padding: 10px 20px;
    border: 2px solid white;
    border-radius: 0; /* Removed rounded corners */
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 16px;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 160px;
}

.character-select-button:hover {
    background-color: black; /* No change on hover */
    border-color: white; /* No change on hover */
}

.character-select-button.selected {
    background-color: black; /* Changed to black */
    border-color: white; /* Changed to white */
}

.character-select-button.selected:hover {
    background-color: black; /* No change on hover */
    border-color: white; /* No change on hover */
}

.character-icon {
    width: 48px; /* Set to accommodate largest 2x scaled sprite width (Berdly: 24*2=48) */
    height: 64px; /* Set to accommodate largest 2x scaled sprite height (Susie/Berdly: 32*2=64) */
    object-fit: contain; /* Ensure the image is contained within the bounds without stretching */
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#heart-cursor {
    height: 24px; /* Example size */
    width: 24px;  /* Example size */
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.game-mode-button {
    background: black; /* Changed from #0056b3 to black */
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 0; /* Removed rounded corners */
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 18px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.game-mode-button:hover {
    background-color: black; /* No change on hover */
}

.game-mode-button:active {
    background-color: black; /* Prevent brightness change on click */
}

#controls-info {
    margin-bottom: 40px;
    text-align: center;
}

#controls-info h2 {
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 18px;
    margin-bottom: 20px;
    color: #fff;
    letter-spacing: 2px;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
    max-width: 200px;
    margin-left: auto;
    margin-right: auto;
}

.control-item .key {
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 14px;
    color: #fff;
    background: #333;
    padding: 4px 8px;
    border: 1px solid #555;
    border-radius: 3px;
    min-width: 80px;
    text-align: center;
}

.control-item .action {
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 14px;
    color: #ccc;
}

#loading-bar {
    width: 300px;
    height: 20px;
    border: 2px solid #fff;
    background: #000;
    margin: 20px auto;
    position: relative;
}

#loading-progress {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.3s ease;
}

#loading-text {
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 14px;
    margin-top: 20px;
    opacity: 0.8;
}

#continue-text {
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 16px;
    margin-top: 30px;
    margin-bottom: 40px;
    color: #fff;
    animation: blink 1.5s infinite;
}

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

/* Responsive scaling */
@media (max-width: 680px) {
    #game-container {
        transform: scale(0.8);
    }
}

@media (max-width: 520px) {
    #game-container {
        transform: scale(0.6);
    }
}

/* Chat styles */
#chat-container {
    position: fixed; /* Changed from absolute to fixed */
    bottom: 10px;
    left: 10px;
    width: 300px;
    height: 150px;
    background: rgba(0, 0, 0, 0.7); /* Semi-transparent background */
    border: 2px solid #555;
    flex-direction: column;
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 12px;
    color: #fff;
    z-index: 900; /* Below inspector, above game */
    pointer-events: none; /* Initially ignore mouse events */
    opacity: 0; /* Initially hidden */
    transition: opacity 0.3s ease-in-out;
}

#chat-container.active {
    opacity: 1; /* Add opacity transition */
    pointer-events: auto; /* Enable mouse events when active */
}

#chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px;
    word-wrap: break-word;
    white-space: pre-wrap; /* Preserve whitespace and wrap text */
    /* Custom scrollbar for aesthetics */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #888 #333; /* Firefox */
}

#chat-messages::-webkit-scrollbar {
    width: 8px;
}

#chat-messages::-webkit-scrollbar-track {
    background: #333;
}

#chat-messages::-webkit-scrollbar-thumb {
    background-color: #888;
    border-radius: 4px;
    border: 1px solid #555;
}

#chat-messages p {
    margin-bottom: 4px;
    line-height: 1.2;
}

#chat-messages p:last-child {
    margin-bottom: 0;
}

#chat-messages p strong {
    color: #add8e6; /* Light blue for usernames */
    margin-right: 5px;
}

.chat-avatar {
    width: 16px; /* Small size for chat avatar */
    height: 16px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 5px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#chat-input {
    width: calc(100% - 16px); /* Full width minus padding */
    padding: 8px;
    margin: 8px;
    background: #333;
    border: 1px solid #666;
    color: #eee;
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 12px;
    outline: none;
    pointer-events: auto; /* Always allow typing in input */
}

#chat-input::placeholder {
    color: #bbb;
}

/* Inspector Window styles - Merged from .npc-spawn-window */
#inspector-window {
    position: fixed;
    top: 50px;
    right: 50px;
    width: 300px;
    background: #1a1a1a; /* Darker background, from NPC spawner */
    border: 2px solid #8B4513; /* Brown/wood-like border, from NPC spawner */
    color: #fff;
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 12px;
    z-index: 1001;
    display: none; /* Controlled by JS */
    padding: 0;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.5); /* Deltarune-esque shadow, from NPC spawner */
    resize: both; /* Allow resizing, from NPC spawner */
    overflow: hidden; /* Prevent content scrollbar from showing outside border */
    min-width: 150px;
    min-height: 100px;
    display: flex; /* Added to use flexbox for title bar + content */
    flex-direction: column;
}

.inspector-title-bar {
    background: #8B4513; /* Title bar color, from NPC spawner */
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab; /* Indicate draggable */
    border-bottom: 1px solid #A0522D;
    color: #fff;
    font-size: 12px;
}

.inspector-title-bar.dragging {
    cursor: grabbing;
}

#inspector-close-btn {
    background: none;
    border: 1px solid #ccc;
    color: #fff;
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 3px;
}

#inspector-close-btn:hover {
    background: #c00;
    border-color: #f00;
}

#inspector-content-area {
    padding: 12px;
    flex-grow: 1; /* Allow content area to expand */
    overflow-y: auto; /* Allow content to scroll */
    display: flex; /* For inner flex layout in some modes */
    flex-direction: column;
    gap: 10px;
    /* Custom scrollbar styles if needed for content area */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #888 #333; /* Firefox */
}

#inspector-content-area::-webkit-scrollbar {
    width: 8px;
}

#inspector-content-area::-webkit-scrollbar-track {
    background: #333;
}

#inspector-content-area::-webkit-scrollbar-thumb {
    background-color: #888;
    border-radius: 4px;
    border: 1px solid #555;
}

/* Re-use existing debug button styles for spawn buttons within inspector */
#inspector-content-area .debug-button {
    width: 100%; /* Make spawn buttons fill width */
    margin: 0; /* Remove existing margin from general debug button style */
}

/* New styles for view switcher buttons */
#inspector-view-switcher {
    display: flex;
    justify-content: center;
    padding: 8px;
    background: #333;
    border-bottom: 1px solid #555;
    gap: 5px;
}

.inspector-switcher-btn {
    background: #444;
    color: #fff;
    border: 1px solid #666;
    padding: 4px 8px;
    cursor: pointer;
    font-family: '8bitOperatorPlus-Bold', 'Courier New', monospace;
    font-size: 10px;
    border-radius: 3px;
    flex-grow: 1; /* Make buttons fill available space */
}

.inspector-switcher-btn:hover {
    background: #555;
}

.inspector-switcher-btn.active {
    background: #8B4513; /* Highlight active button */
    border-color: #A0522D;
    color: #fff;
}

.inspector-switcher-btn.active:hover {
    background: #A0522D; /* Darker hover for active button */
}