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

body {
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#renderCanvas {
    width: 100%;
    height: 100vh;
    display: block;
    cursor: none;
}

#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 20px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

#crosshair::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 2px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

#instructions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    transition: opacity 0.3s;
}

#instructions.hidden {
    opacity: 0;
}

#inventory-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 30, 0.95);
    border: 2px solid #444;
    border-radius: 5px;
    padding: 20px;
    z-index: 100;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    max-width: 90vw;
    overflow: hidden;
}

#inventory-grid {
    position: relative;
    width: 300px;
    height: 400px;
    max-width: 100%;
    background: linear-gradient(90deg, #1a1a2a 1px, transparent 1px),
                linear-gradient(180deg, #1a1a2a 1px, transparent 1px);
    background-size: 50px 50px;
    background-color: #0f0f1a;
    border: 1px solid #333;
    margin: 0 auto;
}

.inventory-cell {
    position: absolute;
    width: 50px;
    height: 50px;
    border: 1px solid rgba(100, 100, 120, 0.2);
    box-sizing: border-box;
    display: inline-block;
    float: left;
}

.inventory-item {
    position: absolute;
    background-color: rgba(40, 60, 80, 0.9);
    border: 2px solid #4a6a8a;
    cursor: grab;
    transition: border-color 0.2s;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.inventory-item:hover {
    border-color: #6a8aaa;
    box-shadow: 0 0 10px rgba(100, 150, 200, 0.5);
}

.inventory-item.dragging {
    cursor: grabbing;
    opacity: 0.8;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.7);
}

#quickbar-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 50;
    background: rgba(10, 10, 20, 0.8);
    padding: 10px;
    border-radius: 5px;
    border: 2px solid #333;
}

.quickbar-slot {
    width: 60px;
    height: 60px;
    background: rgba(30, 30, 40, 0.9);
    border: 2px solid #444;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quickbar-slot:hover {
    border-color: #666;
    background: rgba(40, 40, 50, 0.9);
}

.quickbar-slot.selected {
    border-color: #4a8;
    background: rgba(40, 60, 50, 0.9);
    box-shadow: 0 0 10px rgba(68, 170, 136, 0.5);
}

.quickbar-slot.drag-hover {
    border-color: #48f;
    background: rgba(40, 40, 80, 0.9);
    box-shadow: 0 0 15px rgba(68, 136, 255, 0.6);
}

.slot-number {
    position: absolute;
    top: 2px;
    left: 4px;
    color: #888;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.item-icon {
    width: 50px;
    height: 50px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#player-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 900px;
    height: 80%;
    max-height: 600px;
    background: rgba(15, 15, 25, 0.98);
    border: 2px solid #333;
    border-radius: 5px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
}

#tab-bar {
    display: flex;
    background: rgba(10, 10, 20, 0.9);
    border-bottom: 2px solid #333;
    padding: 0;
}

.tab-button {
    flex: 1;
    padding: 15px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tab-button:hover {
    background: rgba(40, 40, 50, 0.5);
    color: #aaa;
}

.tab-button.active {
    background: rgba(30, 50, 70, 0.7);
    color: #4af;
    border-bottom: 3px solid #4af;
    margin-bottom: -2px;
}

#tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
}

.tab-panel {
    display: none;
    height: 100%;
    overflow-x: hidden;
}

.tab-panel.active {
    display: block;
}

#status-bars {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 51;
}

.status-bar {
    margin-bottom: 10px;
    background: rgba(10, 10, 20, 0.8);
    padding: 5px;
    border-radius: 3px;
    border: 1px solid #333;
}

.bar-label {
    font-size: 11px;
    color: #888;
    margin-bottom: 3px;
    letter-spacing: 1px;
}

.bar-container {
    position: relative;
    width: 200px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    border-radius: 2px;
}

.bar-fill {
    height: 100%;
    transition: width 0.3s, background-color 0.3s;
    border-radius: 2px;
}

.bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.character-sheet {
    color: #ccc;
    padding: 10px;
}

.character-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #333;
}

.character-header h2 {
    margin: 0;
    color: #4af;
    font-size: 24px;
}

.level-info {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: #888;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-section {
    background: rgba(20, 20, 30, 0.5);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #333;
}

.stat-section h3 {
    margin: 0 0 10px 0;
    color: #4a8;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.stat-name {
    flex: 0 0 40%;
    font-size: 12px;
    color: #aaa;
}

.stat-bar {
    flex: 1;
    position: relative;
    height: 16px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    border-radius: 2px;
    margin-left: 10px;
}

.stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #246, #48a);
    border-radius: 2px;
    transition: width 0.3s;
}

.stat-value {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.conditions-section {
    background: rgba(20, 20, 30, 0.5);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #333;
}

.conditions-section h3 {
    margin: 0 0 10px 0;
    color: #4a8;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.condition-good {
    color: #4a8;
    font-size: 14px;
}

.condition-bad {
    color: #f44;
    font-size: 14px;
    margin-right: 10px;
    padding: 2px 6px;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: 3px;
}

.objectives-panel {
    color: #ccc;
    padding: 10px;
}

.objectives-header {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #333;
}

.objectives-header h2 {
    margin: 0;
    color: #4af;
    font-size: 24px;
}

.objectives-sections {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.objective-category {
    background: rgba(20, 20, 30, 0.5);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #333;
}

.objective-category h3 {
    margin: 0 0 10px 0;
    color: #4a8;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.objective-list {
    max-height: 200px;
    overflow-y: auto;
}

.objective-item {
    background: rgba(30, 30, 40, 0.5);
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 3px;
    border-left: 3px solid #48a;
}

.objective-item.completed {
    opacity: 0.6;
    border-left-color: #484;
}

.objective-item.completed .objective-title {
    text-decoration: line-through;
}

.objective-title {
    font-size: 14px;
    color: #fff;
    margin-bottom: 4px;
}

.objective-description {
    font-size: 12px;
    color: #888;
}

.no-objectives {
    color: #666;
    font-style: italic;
    font-size: 12px;
}

.journal-section {
    background: rgba(20, 20, 30, 0.5);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #333;
}

.journal-section h3 {
    margin: 0 0 10px 0;
    color: #4a8;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.journal-entry {
    background: rgba(30, 30, 40, 0.5);
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 3px;
}

.journal-date {
    font-size: 12px;
    color: #48a;
    margin-bottom: 4px;
    font-weight: bold;
}

.journal-text {
    font-size: 13px;
    color: #aaa;
    line-height: 1.4;
}

.menu-button {
    display: block;
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: rgba(30, 50, 70, 0.7);
    border: 2px solid #444;
    border-radius: 5px;
    color: #ccc;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-button:hover {
    background: rgba(40, 60, 80, 0.8);
    border-color: #666;
    color: #fff;
}

.menu-button:active {
    transform: translateY(1px);
}

.menu-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #333;
}

.menu-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.settings-section h3 {
    color: #4a8;
    margin-bottom: 15px;
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(20, 20, 30, 0.5);
    border-radius: 4px;
}

.setting-label {
    color: #ccc;
    font-size: 14px;
}

.setting-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #4af;
    cursor: pointer;
}

.setting-slider {
    width: 120px;
    height: 6px;
    background: rgba(68, 68, 68, 0.5);
    border-radius: 3px;
    outline: none;
    accent-color: #4af;
    cursor: pointer;
}

.setting-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #4af;
    border-radius: 50%;
    cursor: pointer;
}

.setting-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #4af;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.sensitivity-value {
    color: #4af;
    font-size: 12px;
    min-width: 30px;
    text-align: center;
}

#confirmation-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 350px;
    background: rgba(15, 15, 25, 0.98);
    border: 2px solid #f44;
    border-radius: 8px;
    z-index: 400;
    box-shadow: 0 0 50px rgba(255, 0, 0, 0.3);
    padding: 25px;
    text-align: center;
}

.confirmation-title {
    color: #f44;
    font-size: 20px;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.confirmation-message {
    color: #ccc;
    margin-bottom: 20px;
    line-height: 1.4;
}

.confirmation-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-button, .cancel-button {
    padding: 10px 20px;
    border: 2px solid;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.confirm-button {
    background: rgba(255, 68, 68, 0.2);
    border-color: #f44;
    color: #f44;
}

.confirm-button:hover {
    background: rgba(255, 68, 68, 0.4);
}

.cancel-button {
    background: rgba(68, 68, 68, 0.2);
    border-color: #666;
    color: #ccc;
}

.cancel-button:hover {
    background: rgba(68, 68, 68, 0.4);
    border-color: #888;
}

/* Dialogue System Styles */
.dialogue-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    background: rgba(10, 10, 20, 0.98);
    border: 2px solid #4af;
    border-radius: 10px;
    z-index: 300;
    box-shadow: 0 0 50px rgba(68, 170, 255, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    overflow: hidden;
}

.dialogue-container.dialogue-visible {
    opacity: 1;
}

body.dialogue-active {
    overflow: hidden;
}

.npc-dialogue-section {
    padding: 20px;
    border-bottom: 2px solid #333;
    min-height: 150px;
}

.npc-name {
    font-size: 18px;
    font-weight: bold;
    color: #4af;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.npc-portrait {
    width: 60px;
    height: 60px;
    background: rgba(30, 30, 40, 0.8);
    border: 2px solid #444;
    border-radius: 50%;
    float: left;
    margin-right: 15px;
    margin-bottom: 10px;
    background-image: linear-gradient(45deg, #333, #555);
}

.npc-text {
    font-size: 16px;
    line-height: 1.6;
    color: #ccc;
    margin-bottom: 15px;
    overflow-wrap: break-word;
    cursor: pointer;
    min-height: 60px;
}

.npc-text:hover {
    color: #ddd;
}

.response-section {
    padding: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.response-header {
    font-size: 14px;
    color: #888;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.response-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.response-button {
    background: rgba(20, 30, 40, 0.8);
    border: 2px solid #444;
    border-radius: 5px;
    color: #ccc;
    padding: 12px 15px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
    position: relative;
    line-height: 1.4;
}

.response-button:hover,
.response-button.hovered {
    background: rgba(30, 40, 50, 0.9);
    border-color: #666;
    color: #fff;
    transform: translateX(5px);
}

.response-button.selected {
    background: rgba(40, 60, 80, 0.9);
    border-color: #4af;
    color: #4af;
}

.response-button:focus {
    outline: none;
    box-shadow: 0 0 10px rgba(68, 170, 255, 0.5);
}

.response-shortcut {
    display: inline-block;
    background: rgba(68, 170, 255, 0.3);
    color: #4af;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 12px;
    margin-right: 8px;
    min-width: 24px;
    text-align: center;
}

.skill-check-response {
    border-left: 4px solid #f84;
}

.skill-check-indicator {
    color: #f84;
    font-size: 12px;
    font-style: italic;
    opacity: 0.8;
}

.continue-button {
    background: rgba(40, 60, 40, 0.8);
    border-color: #4a8;
    color: #4a8;
    text-align: center;
}

.continue-button:hover {
    background: rgba(50, 70, 50, 0.9);
    border-color: #5a9;
    transform: none;
}

.dialogue-close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.3s;
    padding: 5px;
    line-height: 1;
}

.dialogue-close-button:hover {
    color: #ccc;
}

/* Scrollbar for response section */
.response-section::-webkit-scrollbar {
    width: 8px;
}

.response-section::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.response-section::-webkit-scrollbar-thumb {
    background: rgba(68, 170, 255, 0.5);
    border-radius: 4px;
}

.response-section::-webkit-scrollbar-thumb:hover {
    background: rgba(68, 170, 255, 0.7);
}

/* Animation for dialogue appearance */
@keyframes dialogueFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* Responsive design for dialogue */
@media (max-width: 900px) {
    .dialogue-container {
        width: 95%;
        max-height: 90vh;
    }

    .npc-text {
        font-size: 14px;
    }

    .response-button {
        padding: 10px 12px;
        font-size: 13px;
    }

    .npc-portrait {
        width: 50px;
        height: 50px;
        margin-right: 10px;
    }
}