/* ============================================
   FONT FACE DECLARATIONS - Self-hosted fonts
   ============================================ */
@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 100 1000;
    font-display: swap;
    src: url('../assets/fonts/DM_Sans/DMSans-VariableFont_opsz,wght.ttf') format('truetype-variations');
    src: url('../assets/fonts/DM_Sans/DMSans-VariableFont_opsz,wght.ttf') format('truetype');
}

@font-face {
    font-family: 'DM Sans';
    font-style: italic;
    font-weight: 100 1000;
    font-display: swap;
    src: url('../assets/fonts/DM_Sans/DMSans-Italic-VariableFont_opsz,wght.ttf') format('truetype-variations');
    src: url('../assets/fonts/DM_Sans/DMSans-Italic-VariableFont_opsz,wght.ttf') format('truetype');
}

@font-face {
    font-family: 'Noto Serif';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../assets/fonts/Noto_Serif/NotoSerif-VariableFont_wdth,wght.ttf') format('truetype-variations');
    src: url('../assets/fonts/Noto_Serif/NotoSerif-VariableFont_wdth,wght.ttf') format('truetype');
}

@font-face {
    font-family: 'Noto Serif';
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url('../assets/fonts/Noto_Serif/NotoSerif-Italic-VariableFont_wdth,wght.ttf') format('truetype-variations');
    src: url('../assets/fonts/Noto_Serif/NotoSerif-Italic-VariableFont_wdth,wght.ttf') format('truetype');
}

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

body {
    font-family: 'DM Sans', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
    background: #1a1a2e;
    color: #eee;
    overflow: hidden;
    height: 100vh;
}

/* Ensure all UI elements inherit DM Sans in modern mode */
body:not(.classic-theme-active) * {
    font-family: 'DM Sans', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
}

#app {
    width: 100%;
    height: 100vh;
    position: relative;
}

.screen {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen.hidden {
    display: none;
}

/* Welcome Screen */
#welcome-screen {
    /* Background image - add welcome-bg.jpg to assets/images/ for custom background */
    /* Relative path from CSS file location (css/styles.css -> ../assets/images/welcome-bg.jpg) */
    background-image: url('../assets/images/welcome-bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Fallback gradient if image doesn't exist */
    background-color: #667eea;
    position: relative;
}

#welcome-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Very light overlay to maintain readability while showing background */
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    z-index: 1;
    pointer-events: none;
}

#welcome-screen .welcome-content {
    position: relative;
    z-index: 2;
}

.welcome-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.welcome-content h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #fff;
}

.welcome-content h1 .palace-title {
    font-family: 'Noto Serif', serif;
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ffd700 0%, #ff8c00 50%, #ff4500 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    display: inline-block;
    animation: palace-glow 2s ease-in-out infinite alternate;
    letter-spacing: 2px;
    margin-right: 5px;
}

@keyframes palace-glow {
    from {
        filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
    }
    to {
        filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
    }
}

.welcome-content p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.input-group input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1rem;
    outline: none;
}

.input-group input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.input-group input:focus {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.3);
}

.input-group button {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    background: #4CAF50;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.input-group button:hover {
    background: #45a049;
}

.input-group button:active {
    transform: scale(0.98);
}

.avatar-selection {
    margin-top: 2rem;
}

.avatar-selection p {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.avatar-option {
    width: 60px;
    height: 60px;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.avatar-option canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.avatar-option:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.3);
}

/* Chat Screen */
#chat-screen {
    position: relative;
    background: #0f0f1e;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    pointer-events: none;
}

#chat-input-container {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    pointer-events: auto;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

#chat-input {
    flex: 1;
    min-width: 200px;
    max-width: 500px;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
    outline: none;
    resize: horizontal;
    overflow: hidden;
    white-space: nowrap;
}

#chat-input:focus {
    min-width: 300px;
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#chat-input:focus {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
}

#send-button {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    background: #667eea;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

#send-button:hover {
    background: #5568d3;
}

#send-button:active {
    transform: scale(0.98);
}

/* Floating User List Window - Draggable */
.floating-window {
    position: fixed;
    top: 80px;
    left: 80px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    min-width: 200px;
    max-width: 250px;
    pointer-events: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.floating-window .window-header {
    cursor: move;
}

.floating-window.dragging {
    cursor: grabbing;
    user-select: none;
}

.floating-window.hidden {
    display: none;
}

.window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    cursor: move;
    user-select: none;
}

.window-header h3 {
    font-size: 1rem;
    margin: 0;
    color: #fff;
}

.window-header-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.close-window-btn,
.save-window-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.close-window-btn:hover,
.save-window-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

#user-list {
    padding: 0;
}

#user-list-items {
    padding: 0.5rem;
}

#user-list-items {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

#user-list-items li {
    padding: 0.5rem;
    margin: 0.25rem 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Scrollbar styling */
.avatar-grid::-webkit-scrollbar,
#user-list-items::-webkit-scrollbar {
    width: 8px;
}

.avatar-grid::-webkit-scrollbar-track,
#user-list-items::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.avatar-grid::-webkit-scrollbar-thumb,
#user-list-items::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.avatar-grid::-webkit-scrollbar-thumb:hover,
#user-list-items::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Edit Avatar Button - Discrete */
.edit-avatar-btn {
    position: fixed;
    bottom: 1rem;
    right: 60px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(102, 126, 234, 0.8);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    z-index: 102;
    pointer-events: auto;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.edit-avatar-btn:hover {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}


/* Theme Toggle Button */
.theme-toggle-btn {
    position: fixed;
    top: 1rem;
    right: 60px; /* Positioned to the left of user list button */
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(255, 165, 0, 0.8);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    z-index: 102;
    pointer-events: auto;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.theme-toggle-btn:hover {
    background: rgba(255, 165, 0, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}


/* Toggle Chat Log Button */
.toggle-chat-log-btn {
    position: fixed;
    bottom: 1rem;
    right: 160px; /* Positioned to the left of edit avatar button (which is at 60px) - increased from 110px to avoid overlap */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(138, 43, 226, 0.8);
    border: 2px solid rgba(138, 43, 226, 1);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000 !important; /* Must be above canvas */
    pointer-events: auto !important;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.4);
    padding: 0;
}

.toggle-chat-log-btn:hover {
    background: rgba(138, 43, 226, 1) !important;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(138, 43, 226, 0.6);
    z-index: 10001 !important;
}

/* Shared tooltip styling for all buttons */
.edit-avatar-btn::before,
.theme-toggle-btn::before,
.toggle-chat-log-btn::before,
.toggle-user-list-btn::before,
.settings-btn::before {
    content: attr(title);
    position: absolute;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 0.75rem;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

/* Tooltip positioning - buttons at bottom show tooltip above */
.edit-avatar-btn::before,
.toggle-chat-log-btn::before {
    bottom: 100%;
    right: 50%;
    transform: translateX(50%) translateY(-4px);
    margin-bottom: 8px;
}

/* Tooltip positioning - buttons at top show tooltip below */
.theme-toggle-btn::before,
.toggle-user-list-btn::before,
.settings-btn::before {
    top: 100%;
    right: 50%;
    transform: translateX(50%) translateY(4px);
    margin-top: 8px;
}

/* Shared tooltip arrow styling */
.edit-avatar-btn::after,
.theme-toggle-btn::after,
.toggle-chat-log-btn::after,
.toggle-user-list-btn::after,
.settings-btn::after {
    content: '';
    position: absolute;
    border: 4px solid transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

/* Tooltip arrows for buttons at bottom (arrow points up) */
.edit-avatar-btn::after,
.toggle-chat-log-btn::after {
    bottom: 100%;
    right: 50%;
    transform: translateX(50%) translateY(-4px);
    margin-bottom: 2px;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Tooltip arrows for buttons at top (arrow points down) */
.theme-toggle-btn::after,
.toggle-user-list-btn::after,
.settings-btn::after {
    top: 100%;
    right: 50%;
    transform: translateX(50%) translateY(4px);
    margin-top: -2px;
    border-bottom-color: rgba(0, 0, 0, 0.9);
}

/* Show tooltips on hover */
.edit-avatar-btn:hover::before,
.theme-toggle-btn:hover::before,
.toggle-chat-log-btn:hover::before,
.toggle-user-list-btn:hover::before,
.settings-btn:hover::before,
.edit-avatar-btn:hover::after,
.theme-toggle-btn:hover::after,
.toggle-chat-log-btn:hover::after,
.toggle-user-list-btn:hover::after,
.settings-btn:hover::after {
    opacity: 1;
    transform: translateX(50%) translateY(0);
}

/* Toggle User List Button */
.toggle-user-list-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    z-index: 101;
    pointer-events: auto;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.toggle-user-list-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}


/* Settings Button */
.settings-btn {
    position: fixed;
    top: 1rem;
    right: 110px; /* Positioned to the left of user list button (which is at 1rem = 16px) - increased from 60px to avoid overlap */
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    z-index: 101;
    pointer-events: auto;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.settings-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}


/* Avatar Editor Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: auto !important; /* Ensure modal is interactive */
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #1a1a2e;
    padding: 0;
    border-radius: 12px;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    pointer-events: auto !important; /* Ensure modal content is interactive */
}

.modal-content * {
    pointer-events: auto !important; /* Ensure all elements inside are interactive */
}

#settings-container,
#settings-container * {
    pointer-events: auto !important; /* Ensure settings container and all its children are interactive */
}

/* Settings styling for modern mode */
#settings-container {
    padding: 1rem;
    color: #eee;
}

.settings-section {
    margin-bottom: 1.5rem;
}

.settings-label {
    display: flex;
    align-items: center;
    font-size: 1.25rem; /* Increased from 1rem by 4px equivalent */
    color: #eee;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.settings-label input[type="checkbox"] {
    width: 24px; /* Increased from 20px */
    height: 24px; /* Increased from 20px */
    margin-right: 0.5rem;
    cursor: pointer;
    pointer-events: auto !important;
}

.settings-label input[type="number"] {
    width: 80px;
    margin-left: 0.5rem;
    padding: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.25rem; /* Increased from 1rem by 4px equivalent */
    pointer-events: auto !important;
    cursor: text;
}

.settings-hint {
    font-size: 1.0625rem; /* Increased from 0.85rem by 4px equivalent (0.85rem = 13.6px, +4px = 17.6px = 1.0625rem) */
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.25rem;
    margin-bottom: 0;
}

/* Theme option buttons - Modern Mode */
.theme-radio-group {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-top: 8px;
}

/* Disconnect button - Modern Mode */
.disconnect-btn {
    padding: 8px 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: #eee;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: auto !important;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.disconnect-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

.disconnect-btn:active {
    background: rgba(255, 0, 0, 0.2);
    border-color: rgba(255, 0, 0, 0.5);
    transform: translateY(1px);
}

.theme-option-btn {
    padding: 8px 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: #eee;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: auto !important;
}

.theme-option-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

.theme-option-btn:active {
    background: rgba(74, 158, 255, 0.3);
    border-color: #4a9eff;
}

/* Selected state */
.theme-option-btn.selected {
    background: rgba(74, 158, 255, 0.4);
    border-color: #4a9eff;
    color: #fff;
    box-shadow: 0 0 10px rgba(74, 158, 255, 0.3);
}



.modal-content .window-header {
    flex-shrink: 0;
}

.modal-content #avatar-editor-container {
    padding: 1rem;
    overflow-y: auto;
}

.avatar-editor {
    color: #eee;
}

.avatar-editor h2 {
    margin-bottom: 1rem;
    color: #fff;
    font-size: 1.2rem;
}

.editor-section {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.editor-section h3 {
    margin-bottom: 0.5rem;
    color: #fff;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.editor-hint {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
}

.editor-tooltip {
    font-size: 0.75rem;
    cursor: help;
    opacity: 0.7;
    position: relative;
    display: inline-block;
}

.editor-tooltip::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 5px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 0.7rem;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateX(-50%) translateY(-4px);
    z-index: 1000;
    max-width: 200px;
    white-space: normal;
    text-align: center;
}

.editor-tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.editor-controls-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.editor-controls-row input[type="file"] {
    flex: 1;
    font-size: 0.85rem;
}

.layer-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

#avatar-preview-container {
    margin-top: 0.5rem;
    text-align: center;
}

#avatar-preview {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    cursor: crosshair;
    max-width: 100%;
    height: auto;
}

.props-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.props-controls input[type="file"] {
    display: none;
}

.props-controls button,
.editor-actions button,
.layer-controls button {
    padding: 0.4rem 0.8rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.3s;
}

.props-controls button:hover,
.editor-actions button:hover,
.layer-controls button:hover {
    background: #5568d3;
}

#props-list {
    margin-top: 1rem;
}

.prop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin: 0.25rem 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.prop-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.prop-item.selected {
    background: rgba(102, 126, 234, 0.3);
    border: 1px solid #667eea;
}

.remove-prop {
    padding: 0.25rem 0.5rem;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.remove-prop:hover {
    background: #cc0000;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: center;
}

.editor-actions button {
    min-width: 80px;
    padding: 0.5rem 1rem;
}

/* Default Avatar Picker - Palace Style */
.default-avatar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.25rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    border-radius: 0;
    max-width: 300px;
}

.default-avatar-face {
    width: 32px;
    height: 32px;
    border: 1px solid #808080;
    border-radius: 50%;
    cursor: pointer;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    object-fit: contain;
    background: #fff;
    padding: 2px;
    display: block;
    margin: 0 auto;
}

.default-avatar-face:hover {
    border-color: #000;
    background: #e0e0e0;
}

.default-avatar-face.selected {
    border-color: #000;
    border-width: 2px;
    background: #ffff00;
    box-shadow: inset 0 0 0 1px #000;
}

.color-picker {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    border-radius: 0;
    max-width: 300px;
}

.color-option {
    width: 20px;
    height: 20px;
    border: 1px solid #808080;
    cursor: pointer;
    display: inline-block;
}

.color-option:hover {
    border-color: #000;
    border-width: 2px;
}

.color-option.selected {
    border-color: #000;
    border-width: 2px;
    box-shadow: inset 0 0 0 1px #fff, 0 0 0 1px #000;
}

/* Discord Activity specific styles */
body.discord-activity {
    /* Discord's iframe has specific dimensions - ensure no overflow */
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

body.discord-activity #welcome-screen {
    /* Adjust welcome screen for Discord's viewport */
    padding: 1rem;
}

body.discord-activity .welcome-content {
    max-width: 100%;
    padding: 1.5rem;
    margin: 1rem;
}

body.discord-activity .welcome-content h1 {
    font-size: 2rem; /* Smaller for Discord */
}

body.discord-activity .welcome-content p {
    font-size: 0.95rem;
}

/* Ensure chat input is always accessible in Discord */
body.discord-activity #chat-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    margin: 0;
    padding: 0.75rem;
}

/* Make UI more compact for Discord */
body.discord-activity #game-container {
    height: calc(100vh - 60px); /* Account for chat input */
}

/* Adjust button positions for Discord */
body.discord-activity .edit-avatar-btn {
    bottom: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    font-size: 1rem;
}

body.discord-activity .theme-toggle-btn {
    top: 0.5rem;
    right: 50px;
    width: 36px;
    height: 36px;
    font-size: 1rem;
}

body.discord-activity .toggle-chat-log-btn {
    bottom: 0.5rem;
    right: 50px; /* Positioned to the left of edit avatar button in Discord */
    width: 36px;
    height: 36px;
    font-size: 1rem;
}

body.discord-activity .toggle-user-list-btn {
    top: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    font-size: 1rem;
}

/* Optimize floating windows for Discord */
body.discord-activity .floating-window {
    max-width: 200px;
    font-size: 0.9rem;
}

/* Ensure modals work in Discord iframe */
body.discord-activity .modal {
    position: fixed;
    z-index: 2000;
}

