/* Soul Searcher - Main Styles */

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

html, body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    touch-action: manipulation;
}

/* Quest Tracker - Compact always-visible progress tracker */
.quest-tracker {
    position: fixed;
    top: 70px;
    right: 15px;
    width: 280px;
    min-height: 60px;
    background: rgba(15, 25, 15, 0.92);
    border: 1.5px solid #6b8b6b;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.2);
    backdrop-filter: blur(8px);
    z-index: 1000;
    font-family: 'Crimson Text', serif;
    transition: all 0.3s ease;
}

.quest-tracker:hover {
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
    border-color: #8ba58b;
}

.quest-tracker-content {
    padding: 10px 12px;
}

.quest-tracker-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.quest-tracker-icon {
    font-size: 14px;
    color: #d4af37;
}

.quest-tracker-title {
    font-size: 13px;
    font-weight: 600;
    color: #d4af37;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.quest-tracker-objective {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.objective-text {
    font-size: 12px;
    color: #b8c8b8;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.objective-progress {
    font-size: 11px;
    color: #8fbc8f;
    font-weight: 600;
    text-align: right;
    background: rgba(143, 188, 143, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(143, 188, 143, 0.2);
}

.quest-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(20, 30, 20, 0.8);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(143, 188, 143, 0.3);
    margin-top: 4px;
}

.quest-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #d4af37, #f4d03f);
    border-radius: 4px;
    transition: width 0.4s ease;
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.5);
    min-width: 2px;
}

/* Mobile responsiveness for quest tracker */
@media (max-width: 768px) {
    .quest-tracker {
        width: 250px;
        top: 60px;
        right: 10px;
    }
    
    .quest-tracker-title {
        font-size: 12px;
    }
    
    .objective-text {
        font-size: 11px;
    }
    
    /* Adjust notification stack for mobile to be below quest tracker */
    #notificationStack {
        top: 170px; /* well below mobile quest tracker */
        left: 10px;
        right: 10px;
    }
}

/* Orb Companion Chat System */
.orb-chat-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    height: 70%;
    max-height: 600px;
    background: rgba(15, 25, 15, 0.95);
    border: 2px solid #6b8b6b;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 2000;
    font-family: 'Crimson Text', serif;
    backdrop-filter: blur(10px);
}

.orb-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #4a3a2a;
    background: rgba(20, 15, 10, 0.8);
    border-radius: 10px 10px 0 0;
}

.orb-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d4af37;
    font-size: 16px;
    font-weight: 600;
}

.orb-icon {
    font-size: 20px;
    animation: orb-glow 2s ease-in-out infinite alternate;
}

@keyframes orb-glow {
    0% { text-shadow: 0 0 5px rgba(212, 175, 55, 0.5); }
    100% { text-shadow: 0 0 15px rgba(212, 175, 55, 0.8), 0 0 25px rgba(255, 255, 200, 0.3); }
}

.orb-chat-close {
    background: none;
    border: none;
    color: #8b7355;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
}

.orb-chat-close:hover {
    color: #d4af37;
    background: rgba(212, 175, 55, 0.1);
}

.orb-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.orb-chat-message {
    display: flex;
    margin-bottom: 10px;
}

.orb-chat-message.user-message {
    justify-content: flex-end;
}

.orb-chat-message.orb-message {
    justify-content: flex-start;
}

.orb-chat-message-content {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 12px;
    position: relative;
}

.user-message .orb-chat-message-content {
    background: rgba(107, 139, 107, 0.3);
    border: 1px solid #6b8b6b;
    color: #e8ddc3;
}

.orb-message .orb-chat-message-content {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid #d4af37;
    color: #c9a876;
}

.orb-chat-message-text {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 5px;
}

.orb-chat-message-time {
    font-size: 11px;
    opacity: 0.6;
    text-align: right;
}

.orb-chat-input-area {
    padding: 15px;
    border-top: 1px solid #4a3a2a;
    background: rgba(20, 15, 10, 0.8);
    border-radius: 0 0 10px 10px;
}

.orb-chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.orb-chat-option {
    background: rgba(107, 139, 107, 0.8);
    border: 1px solid #6b8b6b;
    border-radius: 20px;
    padding: 6px 12px;
    color: #e8ddc3;
    font-family: 'Crimson Text', serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.orb-chat-option:hover {
    background: rgba(107, 139, 107, 1);
    border-color: #d4af37;
    transform: translateY(-1px);
}

.orb-chat-option:active {
    transform: translateY(0);
}

.orb-chat-input-controls {
    display: flex;
    gap: 10px;
}

.orb-chat-input {
    flex: 1;
    background: rgba(15, 25, 15, 0.8);
    border: 1px solid #6b8b6b;
    border-radius: 6px;
    padding: 10px 12px;
    color: #e8ddc3;
    font-family: 'Crimson Text', serif;
    font-size: 14px;
}

.orb-chat-input:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.orb-chat-send {
    background: rgba(107, 139, 107, 0.3);
    border: 1px solid #6b8b6b;
    border-radius: 6px;
    padding: 10px 15px;
    color: #e8ddc3;
    cursor: pointer;
    font-family: 'Crimson Text', serif;
    font-size: 14px;
    transition: all 0.2s;
}

.orb-chat-send:hover {
    background: rgba(107, 139, 107, 0.5);
    border-color: #d4af37;
}

.orb-chat-loading {
    padding: 10px;
    text-align: center;
    color: #8b7355;
    font-style: italic;
}

.loading-dots {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #d4af37;
    border-radius: 50%;
    animation: loading-bounce 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes loading-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mobile responsive for chat */
@media (max-width: 768px) {
    .orb-chat-container {
        width: 95%;
        height: 80%;
        max-height: 500px;
    }
    
    .orb-chat-message-content {
        max-width: 90%;
    }
    
    .orb-chat-input-area {
        padding: 10px;
    }
    
    .orb-chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    #focusHelper {
        min-width: 90vw;
        padding: 20px;
    }
    
    #focusHelper .welcome-sections {
        gap: 15px;
    }
    
    #focusHelper .welcome-section {
        padding: 12px;
    }
    
    #focusHelper .welcome-section h3 {
        font-size: 13px;
    }
    
    #focusHelper .welcome-section p,
    #focusHelper .welcome-section li {
        font-size: 11px;
    }
    
    #focusHelper #welcome-continue {
        padding: 10px 20px;
        font-size: 13px;
    }
}

body {
    background: linear-gradient(135deg, #0d1a0d 0%, #0a1308 50%, #061006 100%);
    color: #e8ddc3;
    font-family: 'Crimson Text', serif;
    overflow: hidden;
    cursor: crosshair;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#mapCanvas {
    position: absolute;
    top: 0;
    left: 0;
    image-rendering: pixelated;
    z-index: 1;
}

#atmosphere {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: 
        radial-gradient(ellipse at center, transparent 0%, rgba(10, 19, 8, 0.6) 70%, rgba(6, 16, 6, 0.9) 100%),
        radial-gradient(circle at 20% 80%, rgba(26, 46, 26, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(19, 33, 19, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(13, 26, 13, 0.05) 0%, transparent 30%);
}

/* Title Container */
#titleContainer {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 25, 15, 0.85);
    padding: 6px 14px;
    border: 2px solid #6b8b6b;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(45, 74, 45, 0.3);
    font-size: 11px;
    min-width: 110px;
    z-index: 10;
    text-align: center;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#titleContainer h3 {
    margin-bottom: 0;
    font-size: 15px;
}

#titleContainer div {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    font-size: 10px;
}

/* Stats Container */
#statsContainer {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(15, 25, 15, 0.85);
    padding: 10px 12px;
    border: 2px solid #6b8b6b;
    border-radius: 8px;
    box-shadow: 0 0 12px rgba(45, 74, 45, 0.25);
    font-size: 20px;
    min-width: 220px;
    max-width: 320px;
    width: 310px;
    z-index: 10;
}

#statsContainer .stat-bar {
    position: relative;
    width: 100%;
    height: 24px;
    margin-bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #4a3a2a;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

#statsContainer .stat-bar-text {
    position: absolute;
    font-size: 16px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    z-index: 2;
    white-space: nowrap;
}

#statsContainer .stat-label {
    color: #c9a876;
    font-size: 18px;
    min-width: 32px;
    text-align: right;
    margin-right: 8px;
    text-shadow: 0 0 3px rgba(201, 168, 118, 0.5);
}

/* Currency Tracker HUD */
#currencyTracker {
    display: flex;
    align-items: center;
    justify-content: space-around;
    margin-top: 6px;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border: 1px solid rgba(107, 139, 107, 0.3);
}

.currency-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

.currency-icon-sm {
    font-size: 14px;
    line-height: 1;
}

.currency-val {
    font-size: 13px;
    font-weight: bold;
    color: #c9a876;
    font-family: 'Cinzel', serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    min-width: 20px;
}

/* Minimap Container */
#minimapContainer {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#minimapToggle {
    position: absolute;
    left: 0;
    bottom: 0;
    margin: 8px;
    z-index: 20;
    background: rgba(15, 25, 15, 0.95);
    border: 2px solid #6b8b6b;
    border-radius: 6px 0 0 0;
    color: #d4af37;
    font-size: 16px;
    padding: 4px 8px;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(139, 115, 85, 0.2);
    transition: all 0.2s;
}

#minimapToggle:hover {
    background: rgba(107, 139, 107, 0.8);
    color: #c9d176;
}

#minimapContainer.collapsed #minimap {
    display: none;
}

#minimapContainer.collapsed #minimapToggle {
    border-radius: 8px;
}

/* Location Info - moved below stats */
#locationInfo {
    position: absolute;
    top: 195px;
    left: 10px;
    background: rgba(15, 25, 15, 0.85);
    padding: 10px;
    border: 2px solid #6b8b6b;
    border-radius: 8px;
    font-size: 12px;
    min-width: 180px;
    max-width: 200px;
    z-index: 10;
    box-shadow: 0 0 10px rgba(139, 115, 85, 0.2);
    font-family: 'Crimson Text', serif;
}

/* Menu Icons */
.menu-icons {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
    z-index: 15;
}

.menu-icon {
    width: 45px;
    height: 45px;
    background: rgba(20, 15, 10, 0.9);
    border: 2px solid #8b7355;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 10px rgba(139, 115, 85, 0.2);
}

.menu-icon:hover {
    background: rgba(139, 115, 85, 0.3);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
}

/* Menu Panels */
.menu-panel {
    position: absolute;
    top: 70px;
    right: 10px;
    background: rgba(20, 15, 10, 0.95);
    padding: 25px;
    border: 2px solid #8b7355;
    border-radius: 8px;
    font-size: 14px;
    min-width: 320px;
    max-width: 400px;
    max-height: calc(100vh - 140px);
    display: none;
    z-index: 1000;
    box-shadow: 0 0 30px rgba(139, 115, 85, 0.4);
    font-family: 'Crimson Text', serif;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.menu-panel.show {
    opacity: 1;
    transform: translateX(0);
}

.menu-panel.hide {
    opacity: 0;
    transform: translateX(20px);
}

/* Enhanced Crafting Panel */
#craftingPanel {
    right: 10px;
    min-width: 520px;
    max-width: 600px;
    min-height: 700px;
}

.crafting-panel {
    display: flex;
    flex-direction: column;
}

.crafting-header {
    margin-bottom: 15px;
    text-align: center;
}

.crafting-subtitle {
    color: #c9a876;
    font-size: 12px;
    font-style: italic;
}

/* Crafting Tabs */
.crafting-tabs {
    display: flex;
    background: rgba(20, 15, 10, 0.5);
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
}

.crafting-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 8px;
    color: #8b7355;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: inherit;
}

.crafting-tab:hover {
    background: rgba(139, 115, 85, 0.2);
    color: #c9a876;
}

.crafting-tab.active {
    background: rgba(212, 175, 55, 0.2);
    color: #d4af37;
    box-shadow: inset 0 -3px 0 #d4af37;
}

.tab-icon {
    font-size: 16px;
}

.tab-label {
    font-size: 10px;
    font-weight: 600;
}

/* Resource Display */
.crafting-resources {
    background: rgba(20, 15, 10, 0.5);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.resource-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: rgba(139, 115, 85, 0.1);
    border-radius: 6px;
    transition: all 0.2s;
}

.resource-item:hover {
    background: rgba(139, 115, 85, 0.2);
    transform: scale(1.05);
}

.resource-icon {
    font-size: 16px;
}

.resource-count {
    font-size: 11px;
    color: #c9a876;
    font-weight: 600;
}

/* Crafting Content */
.crafting-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Search and Filters */
.crafting-search {
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(20, 15, 10, 0.8);
    border: 1px solid #4a3a2a;
    border-radius: 6px;
    color: #c9a876;
    font-family: inherit;
    font-size: 12px;
    margin-bottom: 8px;
}

.search-input:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

.search-input::placeholder {
    color: #8b7355;
}

.search-filters {
    display: flex;
    gap: 8px;
}

.filter-btn {
    flex: 1;
    padding: 6px 12px;
    background: rgba(20, 15, 10, 0.5);
    border: 1px solid #4a3a2a;
    border-radius: 4px;
    color: #8b7355;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 11px;
}

.filter-btn:hover {
    background: rgba(139, 115, 85, 0.2);
    color: #c9a876;
}

.filter-btn.active {
    background: rgba(212, 175, 55, 0.2);
    border-color: #d4af37;
    color: #d4af37;
}

/* Recipe List */
.crafting-recipes {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    max-height: 300px;
}

.recipe-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(139, 115, 85, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.recipe-card:hover {
    background: rgba(139, 115, 85, 0.2);
    border-color: #8b7355;
    transform: translateX(4px);
}

.recipe-card.selected {
    background: rgba(212, 175, 55, 0.15);
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.recipe-card.unavailable {
    opacity: 0.5;
    cursor: not-allowed;
}

.recipe-card.unavailable:hover {
    transform: none;
    border-color: transparent;
    background: rgba(139, 115, 85, 0.1);
}

.recipe-card.owned {
    opacity: 0.4;
    cursor: not-allowed;
}

.recipe-card.owned:hover {
    transform: none;
    border-color: transparent;
    background: rgba(139, 115, 85, 0.1);
}

.recipe-card-icon {
    font-size: 24px;
    min-width: 32px;
    text-align: center;
}

.recipe-card-info {
    flex: 1;
}

.recipe-card-name {
    color: #d4af37;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}

.recipe-card-description {
    color: #c9a876;
    font-size: 11px;
    margin-bottom: 4px;
}

.recipe-card-cost {
    font-size: 10px;
    color: #8b7355;
}

.recipe-card-status {
    min-width: 60px;
    text-align: right;
}

.status-badge {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-available {
    background: rgba(123, 160, 91, 0.3);
    color: #7ba05b;
}

.status-unavailable {
    background: rgba(139, 0, 0, 0.3);
    color: #ff6b6b;
}

.status-owned {
    background: rgba(100, 100, 100, 0.3);
    color: #8b8b8b;
}

.status-discovered {
    background: rgba(212, 175, 55, 0.3);
    color: #d4af37;
}

/* Recipe Details */
.recipe-details {
    background: rgba(20, 15, 10, 0.8);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #4a3a2a;
}

.recipe-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #4a3a2a;
}

.recipe-icon {
    font-size: 48px;
    min-width: 60px;
    text-align: center;
}

.recipe-name {
    color: #d4af37;
    font-size: 16px;
    margin-bottom: 4px;
}

.recipe-description {
    color: #c9a876;
    font-size: 12px;
    line-height: 1.4;
}

.recipe-materials h5 {
    color: #d4af37;
    font-size: 13px;
    margin-bottom: 10px;
}

.materials-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 15px;
}

.material-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(139, 115, 85, 0.1);
    border-radius: 6px;
}

.material-icon {
    font-size: 16px;
}

.material-info {
    flex: 1;
}

.material-name {
    font-size: 11px;
    color: #c9a876;
}

.material-count {
    font-size: 10px;
    font-weight: 600;
}

.material-count.sufficient {
    color: #7ba05b;
}

.material-count.insufficient {
    color: #ff6b6b;
}

/* Recipe Actions */
.recipe-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px solid #4a3a2a;
}

.quantity-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 28px;
    height: 28px;
    background: rgba(139, 115, 85, 0.3);
    border: 1px solid #4a3a2a;
    border-radius: 4px;
    color: #c9a876;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-weight: 600;
}

.qty-btn:hover {
    background: rgba(139, 115, 85, 0.5);
    border-color: #8b7355;
}

.qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#craftQuantity {
    width: 50px;
    text-align: center;
    padding: 6px;
    background: rgba(20, 15, 10, 0.8);
    border: 1px solid #4a3a2a;
    border-radius: 4px;
    color: #c9a876;
    font-family: inherit;
}

#craftQuantity:focus {
    outline: none;
    border-color: #d4af37;
}

.craft-btn {
    flex: 1;
    padding: 10px 20px;
    background: linear-gradient(135deg, #d4af37, #b8941f);
    border: none;
    border-radius: 6px;
    color: #2a1f0f;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.craft-btn:hover {
    background: linear-gradient(135deg, #e6c047, #ca9f2a);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(212, 175, 55, 0.3);
}

.craft-btn:disabled {
    background: rgba(139, 115, 85, 0.3);
    color: #8b7355;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.craft-btn:active {
    transform: translateY(0);
}

.craft-text {
    position: relative;
    z-index: 1;
}

#questPanel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    height: 80vh;
    max-width: 1400px;
    max-height: 800px;
    background: linear-gradient(135deg, rgba(20, 15, 10, 0.98), rgba(40, 30, 20, 0.95));
    border: 3px solid rgba(212, 175, 55, 0.6);
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.3), 0 0 80px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-sizing: border-box; /* Ensure border is included in size calculation */
    min-height: 600px; /* Ensure minimum height for content */
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    color: #8b7355;
    font-size: 20px;
    transition: all 0.2s;
}

.close-btn:hover {
    color: #d4af37;
    transform: scale(1.2);
}



/* Item Details Panel */
.item-details-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 420px;
    max-width: 90vw;
    background: linear-gradient(135deg, 
        rgba(15, 10, 8, 0.98) 0%, 
        rgba(25, 18, 12, 0.98) 30%,
        rgba(35, 25, 18, 0.98) 70%,
        rgba(40, 30, 20, 0.98) 100%);
    border: 3px solid #d4af37;
    border-radius: 16px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.9), 
        0 0 40px rgba(212, 175, 55, 0.4),
        0 0 80px rgba(212, 175, 55, 0.2),
        inset 0 2px 4px rgba(255, 255, 255, 0.1),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
    z-index: 10010;
    display: none;
    animation: item-details-appear 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes item-details-appear {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.item-details-panel.show {
    display: block;
}

.item-details-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.1) 0%, rgba(212, 175, 55, 0.05) 100%);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 10px 10px 0 0;
}

.item-details-icon {
    width: 48px;
    height: 48px;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.item-details-info {
    flex: 1;
}

.item-details-name {
    color: #d4af37;
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 4px 0;
}

.item-details-type {
    color: #8b7355;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.item-details-close {
    background: none;
    border: none;
    color: #c9a876;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.item-details-close:hover {
    background: rgba(212, 175, 55, 0.1);
    color: #d4af37;
}

.item-details-content {
    padding: 16px;
}

.item-details-description {
    color: #c9a876;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 16px;
    font-style: italic;
}

.item-details-stats {
    margin-bottom: 20px;
}

.item-details-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.quantity-controls .qty-btn {
    width: 32px;
    height: 32px;
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid #d4af37;
    color: #d4af37;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.quantity-controls .qty-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.quantity-controls .qty-btn:disabled {
    background: rgba(50, 40, 30, 0.3);
    border-color: #5a4a3a;
    color: #5a4a3a;
    cursor: not-allowed;
}

#itemQuantity {
    width: 60px;
    height: 32px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #8b7355;
    color: #e8d7c3;
    text-align: center;
    border-radius: 4px;
    font-family: 'Crimson Text', serif;
    font-size: 14px;
}

#itemQuantity:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.action-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Crimson Text', serif;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-btn.primary {
    background: linear-gradient(135deg, #d4af37 0%, #f4d03f 100%);
    color: #2c1810;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, #f4d03f 0%, #f7dc6f 100%);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.5);
    transform: translateY(-1px);
}

.action-btn.secondary {
    background: rgba(139, 115, 85, 0.1);
    border: 1px solid #8b7355;
    color: #c9a876;
}

.action-btn.secondary:hover {
    background: rgba(139, 115, 85, 0.2);
    color: #e8d7c3;
}

/* Backdrop for item details */
.item-details-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10009;
    display: none;
}

.item-details-backdrop.show {
    display: block;
    animation: backdrop-fade-in 0.3s ease;
}

@keyframes backdrop-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Stats */
.stat-line {
    margin: 6px 0;
    display: flex;
    justify-content: space-between;
    min-width: 220px;
    font-size: 13px;
}

.stat-label {
    color: #c9a876;
    text-shadow: 0 0 3px rgba(201, 168, 118, 0.5);
}

.stat-value {
    color: #e8d7c3;
    text-shadow: 0 0 3px rgba(232, 215, 195, 0.3);
    font-weight: 600;
}

/* Progress Bar Stats */
.stat-bar-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    margin: 8px 0;
    gap: 10px;
}

#statsContainer .stat-bar {
    position: relative;
    width: 100%;
    height: 54px; /* Reduced from 72px */
    margin-bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #4a3a2a;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

#statsContainer .stat-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 9px;
}

#statsContainer .health-fill {
    background: linear-gradient(90deg, #8b0000 0%, #ff4444 50%, #ff6666 100%);
    box-shadow: 0 0 8px rgba(255, 68, 68, 0.6);
}

#statsContainer .mana-fill {
    background: linear-gradient(90deg, #1e3a8a 0%, #3b82f6 50%, #60a5fa 100%);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}

#statsContainer .xp-fill {
    background: linear-gradient(90deg, #92400e 0%, #f59e0b 50%, #fbbf24 100%);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

#statsContainer .stat-bar-text {
    position: absolute;
    font-size: 32px; /* Reduced from 44px */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    z-index: 2;
    white-space: nowrap;
}

/* Level display styling */
.level-display {
    text-align: center;
    border-top: 1px solid rgba(139, 115, 85, 0.3);
}

.level-text {
    color: #8b7355;
    font-size: 15px;
    font-weight: normal;
    opacity: 0.8;
}

@keyframes health-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 68, 68, 0.6); }
    50% { box-shadow: 0 0 15px rgba(255, 68, 68, 0.9); }
}

@keyframes mana-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(59, 130, 246, 0.6); }
    50% { box-shadow: 0 0 15px rgba(59, 130, 246, 0.9); }
}

/* Virtual Joystick */
#joystickZone {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: 15px;
    width: 150px;
    height: 150px;
    z-index: 100;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    display: none;
}

#joystickBase {
    position: absolute;
    width: 130px;
    height: 130px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(20, 15, 10, 0.5);
    border: 2px solid rgba(139, 115, 85, 0.5);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
}

#joystickKnob {
    position: absolute;
    width: 50px;
    height: 50px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(139, 115, 85, 0.7);
    border: 2px solid rgba(212, 175, 55, 0.6);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
    transition: none;
}

#joystickKnob.active {
    background: rgba(212, 175, 55, 0.5);
    border-color: #d4af37;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
}

/* Show joystick on mobile only after game starts */
@media (max-width: 768px) {
    body.game-active #joystickZone {
        display: block;
    }
}

/* Joystick direction indicators (subtle) */
#joystickBase::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80%;
    height: 80%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px dashed rgba(139, 115, 85, 0.15);
}

/* Mobile action buttons */
.mobile-action-buttons {
    position: fixed;
    bottom: 200px;
    left: 20px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    gap: 15px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    border: 2px solid;
    border-radius: 50%;
    font-family: 'Crimson Text', serif;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.action-btn:active {
    transform: scale(0.95);
}

.interact-btn {
    background: rgba(212, 175, 55, 0.9);
    border-color: #d4af37;
    color: #2a1f0f;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
    display: none; /* Hidden by default */
}

.interact-btn.show {
    display: flex; /* Show when there's something to interact with */
}

.interact-btn:active {
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.7);
}

.attack-btn {
    background: rgba(220, 75, 75, 0.9);
    border-color: #dc4b4b;
    color: #2a1f0f;
    box-shadow: 0 0 15px rgba(220, 75, 75, 0.4);
}

.attack-btn:active {
    box-shadow: 0 0 25px rgba(220, 75, 75, 0.7);
}

.attack-btn.charging {
    background: rgba(255, 100, 100, 0.95);
    box-shadow: 0 0 30px rgba(255, 100, 100, 0.8);
    animation: charge-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes charge-pulse {
    0% { 
        box-shadow: 0 0 20px rgba(255, 100, 100, 0.6);
        transform: scale(1);
    }
    100% { 
        box-shadow: 0 0 40px rgba(255, 100, 100, 1.0);
        transform: scale(1.05);
    }
}

.action-icon {
    font-size: 24px;
    line-height: 1;
    margin-bottom: 2px;
}

.action-text {
    font-size: 8px;
    font-weight: bold;
    text-shadow: none;
    line-height: 1;
}

/* Show action buttons only on mobile after game starts */
@media (max-width: 768px) {
    body.game-active .mobile-action-buttons {
        display: flex;
    }
}

/* Adjust action buttons for smaller screens */
@media (max-width: 480px) {
    .mobile-action-buttons {
        bottom: 180px;
        left: 15px;
        gap: 12px;
    }
    
    .action-btn {
        width: 60px;
        height: 60px;
    }
    
    .action-icon {
        font-size: 20px;
    }
    
    .action-text {
        font-size: 7px;
    }
}

@media (max-width: 480px) {
    #controls {
        grid-template-columns: 48px 48px 48px;
        grid-template-rows: 48px 48px 48px;
        gap: 3px;
        touch-action: none;
        bottom: 10px;
        right: 10px;
    }
    .control-btn {
        width: 48px;
        height: 48px;
        font-size: 18px;
        border-radius: 8px;
        border-width: 2px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    .control-btn.special {
        font-size: 24px;
        background: rgba(212, 175, 55, 0.3);
        border-color: #d4af37;
        box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
    }
}

/* Grid Inventory */
#inventoryGrid {
    position: absolute;
    top: 70px;
    right: 10px;
    background: rgba(20, 15, 10, 0.95);
    padding: 25px;
    border: 2px solid #8b7355;
    border-radius: 8px;
    display: none;
    z-index: 1000;
    box-shadow: 0 0 30px rgba(139, 115, 85, 0.4);
    min-width: 420px;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(7, 50px);  /* Changed from 8 to 7 */
    grid-gap: 5px;
    margin-top: 15px;
}

.inventory-slot {
    width: 50px;
    height: 50px;
    background: rgba(40, 30, 20, 0.7);
    border: 1px solid #5a4a3a;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.inventory-slot:hover {
    background: rgba(60, 45, 30, 0.8);
    border-color: #8b7355;
    box-shadow: 0 0 10px rgba(139, 115, 85, 0.3);
}

.inventory-slot.occupied {
    background: rgba(50, 40, 30, 0.8);
}

.inventory-slot.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.inventory-slot.drag-over {
    background: rgba(139, 115, 85, 0.4);
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.6);
    transform: scale(1.05);
    transition: all 0.1s ease;
}

.item-icon {
    font-size: 24px;
}

.item-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 11px;
    color: #d4af37;
    background: rgba(0, 0, 0, 0.7);
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: bold;
}

.inventory-stats {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #4a3a2a;
}

.item-tooltip {
    position: absolute;
    background: rgba(20, 15, 10, 0.98);
    border: 1px solid #d4af37;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 2000;
    min-width: 150px;
    max-width: 200px;
    pointer-events: none;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(2px);
}

.item-tooltip h4 {
    color: #d4af37;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 0 4px rgba(212, 175, 55, 0.5);
}

.item-tooltip p {
    color: #c9a876;
    margin: 3px 0;
    line-height: 1.3;
}

/* Focus Helper */
#focusHelper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 0;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 25, 15, 0.95);
    border: 2px solid #6b8b6b;
    border-radius: 12px;
    z-index: 2000;
    font-family: 'Crimson Text', serif;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
    animation: gentle-glow 3s ease-in-out infinite alternate;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    min-width: 400px;
}

/* Full-screen backdrop behind welcome dialog */
#focusHelper::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: -1;
}

#focusHelper .welcome-content {
    margin: 0;
    max-width: 420px;
    width: 100%;
    padding: 32px 32px;
    box-sizing: border-box;
    /* Remove any border or box-shadow here */
    border: none;
    /* keep other existing styles */
}

#focusHelper .welcome-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 20px 0;
}

#focusHelper .welcome-section {
    background: rgba(20, 15, 10, 0.3);
    border: 1px solid #4a3a2a;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
}

#focusHelper .welcome-section:hover {
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

#focusHelper #welcome-continue {
    background: linear-gradient(135deg, #d4af37, #b8941f);
    color: #2a1f0f;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    font-family: 'Crimson Text', serif;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(212, 175, 55, 0.3);
    -webkit-appearance: none;
    user-select: none;
}

#focusHelper #welcome-continue:hover {
    background: linear-gradient(135deg, #e6c44a, #d4af37);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

#focusHelper #welcome-continue:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

@keyframes gentle-glow {
    0%, 100% { box-shadow: 0 0 30px rgba(139, 115, 85, 0.8); }
    50% { box-shadow: 0 0 50px rgba(139, 115, 85, 1); }
}

/* Location Info */
#locationInfo h4 {
    margin-bottom: 6px;
}

#locationInfo > div {
    margin-top: 0;
    padding-top: 0;
}

#locationDetails:not(.collapsed) > div {
    margin-top: 12px;
    padding-top: 12px;
}

#locationDetails {
    transition: all 0.3s ease-in-out;
    overflow: hidden;
}

#locationDetails.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    padding-top: 0;
}

#locationToggle {
    transition: transform 0.3s ease-in-out;
}

#locationToggle.collapsed {
    transform: rotate(90deg);
}

/* Legacy Dialogue Box - Replaced by NPC Chat System */

/* Notification */
#notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 15, 10, 0.95);
    border: 2px solid #d4af37;
    padding: 25px 50px;
    border-radius: 8px;
    font-size: 20px;
    color: #d4af37;
    display: none;
    z-index: 2000;
    font-family: 'Cinzel', serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: ethereal-glow 0.5s;
}

@keyframes ethereal-glow {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Utility Classes */
button {
    font-weight: 600;
}

.soul-low {
    animation: soul-warning 1s infinite;
}

@keyframes soul-warning {
    0%, 100% { color: #e8d7c3; }
    50% { color: #8b0000; }
}

h3, h4 {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Death Screen */
#death-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    pointer-events: none;
}

#death-text {
    font-size: 48px;
    color: #FF0000;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-family: 'Cinzel', serif;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* Minimap */
canvas#minimap {
    position: absolute !important;
    bottom: 10px !important;
    left: 10px !important;
    top: auto !important;
    right: auto !important;
    width: 200px !important;
    height: 120px !important;
    background: rgba(20, 15, 10, 0.9);
    border: 2px solid #8b7355;
    border-radius: 8px;
    image-rendering: pixelated;
    z-index: 10;
    box-shadow: 0 0 20px rgba(139, 115, 85, 0.3);
    display: block;
}

/* Smooth transitions for UI elements */
#minimap, .menu-icons, #titleContainer, #statsContainer {
    transition: opacity 0.3s ease-in-out;
}

#statsContainer .stat-label {
    color: #c9a876;
    font-size: 24px; /* Reduced from 32px */
    min-width: 32px;
    text-align: right;
    margin-right: 8px;
    text-shadow: 0 0 3px rgba(201, 168, 118, 0.5);
}

#statsContainer .stat-bar {
    width: 100%;
    height: 30px;
    margin-bottom: 0;
}

#statsContainer .stat-bar-text {
    font-size: 19px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Quick Slots */
#quickSlotsContainer {
    position: absolute;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 1000;
    background: rgba(15, 25, 15, 0.9);
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #6b8b6b;
    box-shadow: 0 0 10px rgba(45, 74, 45, 0.3);
}

.quick-slots-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

/* Mobile quick slots layout improvements */
@media (max-width: 768px) {
    .quick-slots-row {
        gap: 6px;
        margin: 4px 0;
    }
}

@media (max-width: 480px) {
    .quick-slots-row {
        gap: 4px;
        margin: 3px 0;
    }
}

.quick-slot {
    width: 48px;
    height: 48px;
    background: rgba(25, 40, 25, 0.9);
    border: 2px solid #4a6a4a;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.quick-slot:hover {
    border-color: #d4af37;
    background: rgba(35, 55, 35, 0.9);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

.quick-slot.empty::after {
    content: '+';
    color: #6b8b6b;
    font-size: 20px;
    font-weight: bold;
}

.quick-slot.assigned {
    border-color: #d4af37;
    background: rgba(201, 209, 118, 0.15);
}

.quick-slot.used {
    background: rgba(212, 175, 55, 0.3);
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.6);
    transform: scale(1.1);
    transition: all 0.2s ease;
}

.quick-slot .slot-icon {
    font-size: 24px;
    line-height: 1;
}

.quick-slot .slot-number {
    position: absolute;
    top: -8px;
    left: -8px;
    background: #6b8b6b;
    color: #e8ddc3;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.quick-slot .slot-quantity {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: rgba(212, 175, 55, 0.9);
    color: #000;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 1px solid #d4af37;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Selection Wheel */
.selection-wheel {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 15, 10, 0.95);
    border: 2px solid #d4af37;
    border-radius: 12px;
    padding: 20px;
    z-index: 2000;
    display: none;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
    min-width: 300px;
}

.selection-wheel.show {
    display: block;
    animation: wheel-appear 0.3s ease;
}

@keyframes wheel-appear {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

@keyframes mobile-wheel-slide {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wheel-header {
    color: #d4af37;
    font-size: 16px;
    font-family: 'Cinzel', serif;
    margin-bottom: 15px;
    text-align: center;
}

.wheel-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.wheel-nav {
    background: rgba(139, 115, 85, 0.3);
    border: 1px solid #8b7355;
    color: #e8d7c3;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.wheel-nav:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: #d4af37;
}

.wheel-item {
    flex: 1;
    text-align: center;
    padding: 15px;
    background: rgba(40, 35, 30, 0.6);
    border: 1px solid #6a5f54;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.wheel-item.skill {
    border-color: #9333ea;
    background: rgba(147, 51, 234, 0.1);
}

.wheel-item.item {
    border-color: #7ba05b;
    background: rgba(123, 160, 91, 0.1);
}

.wheel-item-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

.wheel-item-name {
    color: #e8d7c3;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 4px;
}

.wheel-item-type {
    color: #8b7355;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.wheel-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.wheel-btn {
    background: rgba(139, 115, 85, 0.8);
    border: 1px solid #8b7355;
    color: #e8d7c3;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: 'Crimson Text', serif;
    transition: all 0.2s ease;
}

.wheel-btn:hover {
    background: rgba(212, 175, 55, 0.3);
    border-color: #d4af37;
}

.wheel-btn.primary {
    background: rgba(212, 175, 55, 0.8);
    border-color: #d4af37;
    color: #000;
}

.wheel-btn.primary:hover {
    background: rgba(212, 175, 55, 0.9);
}

/* Mobile backdrop for selection wheel */
.wheel-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wheel-backdrop.show {
    display: block;
    opacity: 1;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    /* Fix height issue by using 100vh instead of 100% */
    #gameContainer {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for better mobile support */
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* Title container - smaller and repositioned */
    #titleContainer {
        top: 5px;
        left: 50%;
        transform: translateX(-50%);
        padding: 6px 10px;
        min-width: 140px;
        font-size: 10px;
        z-index: 45; /* Lower than stats */
    }
    
    #titleContainer h3 {
        font-size: 14px;
        margin-bottom: 0;
    }
    
    /* Hide the quote on mobile */
    #titleContainer div {
        display: none;
    }
    
    /* Stats container - top left position */
    #statsContainer {
        position: fixed;
        top: 10px;
        left: 10px;
        right: auto;
        bottom: auto;
        transform: none;
        width: auto;
        min-width: 240px; /* Doubled from 120px */
        max-width: 300px; /* Doubled from 150px */
        padding: 10px 8px; /* Doubled height: 5px -> 10px */
        background: rgba(20, 15, 10, 0.9);
        z-index: 50;
        font-size: 9px;
    }
    
    #statsContainer .stat-bar-container {
        margin: 2px 0;
        gap: 3px;
    }
    
    #statsContainer .stat-bar {
        height: 30px; /* Reduced from 40px */
    }
    
    #statsContainer .stat-bar-text {
        font-size: 20px; /* Reduced from 28px */
        line-height: 30px; /* Reduced from 40px */
    }
    
    .level-display {
        margin-top: 6px;
        padding-top: 6px;
    }
    
    .level-text {
        font-size: 9px !important;
    }
    
    #statsContainer .stat-label {
        font-size: 16px; /* Reduced from 20px */
        min-width: 18px;
    }
    
    /* Location Info - below stats */
    #locationInfo {
        position: fixed;
        top: 65px;
        left: 10px;
        right: auto;
        bottom: auto;
        width: auto;
        min-width: 120px;
        max-width: 150px;
        padding: 6px;
        font-size: 9px;
        z-index: 40;
    }
    
    #locationInfo h4 {
        font-size: 11px;
        margin-bottom: 3px;
    }
    
    /* Minimap container with toggle - moved to right side above controls */
    #minimapContainer {
        position: fixed;
        bottom: 180px;
        right: 15px;
        z-index: 20;
    }
    
    #minimapToggle {
        font-size: 10px;
        padding: 3px 6px;
        margin-bottom: 3px;
        background: rgba(20, 15, 10, 0.95);
    }
    
    #minimap {
        width: 70px;
        height: 50px;
        background: rgba(20, 15, 10, 0.9);
        border: 2px solid #8b7355;
        border-radius: 6px;
    }
    
    /* Menu icons - smaller and better positioned */
    .menu-icons {
        top: 5px;
        right: 5px;
        gap: 5px;
        z-index: 45;
    }
    
    .menu-icon {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    /* Mobile controls - properly positioned at bottom */
    #controls {
        position: fixed;
        bottom: 10px;
        right: 10px;
        left: auto;
        transform: none;
        grid-template-columns: 45px 45px 45px;
        gap: 2px;
        z-index: 30;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    /* Adjust quick slots for mobile - positioned at bottom left below action buttons */
    #quickSlotsContainer {
        position: fixed;
        bottom: 10px;
        top: auto;
        left: 10px;
        right: auto;
        transform: none;
        flex-direction: column;
        padding: 6px 8px;
        gap: 4px;
        background: rgba(20, 15, 10, 0.9);
        border-radius: 8px;
        border: 1px solid #8b7355;
        z-index: 25;
        width: auto;
    }
    
    .quick-slot {
        width: 40px;
        height: 40px;
        border-width: 2px;
        border-radius: 8px;
    }
    
    .quick-slot .slot-icon {
        font-size: 18px;
    }
    
    .quick-slot .slot-number {
        width: 14px;
        height: 14px;
        font-size: 8px;
        top: -7px;
        left: -7px;
    }
    
    /* Minimap container - smaller */
    #minimapContainer {
        bottom: 180px;
        right: 15px;
    }
    
    #minimapToggle {
        font-size: 9px;
        padding: 2px 5px;
        margin-bottom: 2px;
    }
    
    #minimap {
        width: 60px;
        height: 45px;
    }
    
    /* Controls - more compact */
    #controls {
        bottom: 10px;
        right: 10px;
        grid-template-columns: 40px 40px 40px;
        gap: 2px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* Location info - minimal */
    #locationInfo {
        top: 60px;
        left: 10px;
        max-width: 160px;
        padding: 6px;
        font-size: 9px;
    }
    
    #locationInfo.collapsed {
        padding: 4px 6px;
    }
    
    /* Selection wheel */
    .selection-wheel {
        padding: 12px;
        max-height: 45vh;
    }
    
    .wheel-header {
        font-size: 13px;
        margin-bottom: 10px;
    }
    
    .wheel-nav {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .wheel-item {
        padding: 8px;
    }
    
    .wheel-item-icon {
        font-size: 20px;
        margin-bottom: 3px;
    }
    
    .wheel-item-name {
        font-size: 12px;
        margin-bottom: 1px;
    }
    
    .wheel-item-type {
        font-size: 9px;
    }
    
    .wheel-btn {
        padding: 8px 16px;
        font-size: 12px;
        min-height: 40px;
    }
}

/* Portrait orientation specific adjustments */
@media (max-width: 768px) and (orientation: portrait) {
    /* Quick slots positioned at bottom left */
    #quickSlotsContainer {
        bottom: 10px;
        left: 10px;
        right: auto;
        top: auto;
        transform: none;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        max-width: 110px;
        width: auto;
        padding: 6px 8px;
        z-index: 25;
    }
}

body.mobile.portrait #quickSlotsContainer {
    bottom: 10px !important;
    left: 10px !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    max-width: 254px !important;
    width: auto !important;
    padding: 6px 8px !important;
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    /* Adjust UI for landscape layout */
    #titleContainer {
        top: 5px;
        padding: 5px 10px;
    }
    
    #titleContainer h3 {
        font-size: 14px;
    }
    
    #titleContainer div {
        display: none; /* Hide subtitle in landscape */
    }
    
    /* Stats on the left side */
    #statsContainer {
        top: 10px;
        left: 10px;
        right: auto;
        max-width: 360px; /* Doubled from 180px */
    }
    
    /* Location info below stats */
    #locationInfo {
        top: 70px;
        left: 10px;
        right: auto;
        max-width: 180px;
    }
    
    /* Menu icons on the right */
    .menu-icons {
        top: 5px;
        right: 5px;
    }
    
    /* Quick slots positioned at bottom left */
    #quickSlotsContainer {
        bottom: 10px;
        top: auto;
        left: 10px;
        right: auto;
        transform: none;
        flex-direction: column;
        padding: 6px 8px;
        max-width: 110px;
        width: auto;
    }
    
    .quick-slot {
        width: 40px;
        height: 40px;
        border-width: 2px;
        border-radius: 8px;
    }
    
    .quick-slot .slot-icon {
        font-size: 18px;
    }
    
    .quick-slot .slot-number {
        width: 14px;
        height: 14px;
        font-size: 8px;
        top: -7px;
        left: -7px;
    }
    
    /* Minimap container right side above controls */
    #minimapContainer {
        bottom: 180px;
        right: 15px;
    }
    
    /* Controls on bottom right */
    #controls {
        bottom: 10px;
        right: 10px;
        left: auto;
        transform: none;
    }
}

/* Touch-friendly hover states */
@media (hover: none) {
    .quick-slot:hover {
        border-color: #6a5f54;
        background: rgba(40, 35, 30, 0.9);
        box-shadow: none;
    }
    
    .quick-slot:active {
        border-color: #d4af37;
        background: rgba(60, 55, 50, 0.9);
        box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
    }
    
    .wheel-nav:hover {
        background: rgba(139, 115, 85, 0.3);
        border-color: #8b7355;
    }
    
    .wheel-nav:active {
        background: rgba(212, 175, 55, 0.2);
        border-color: #d4af37;
    }
}

/* Add backdrop for mobile panels */
.panel-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.panel-backdrop.show {
    display: block;
    opacity: 1;
}

/* Body class-based mobile styles for better control */
body.mobile #quickSlotsContainer {
    transition: all 0.3s ease;
}

body.mobile #minimapContainer {
    transition: all 0.3s ease;
}

body.mobile #controls {
    transition: all 0.3s ease;
}

body.mobile #statsContainer {
    transition: all 0.3s ease;
}

body.mobile #locationInfo {
    transition: all 0.3s ease;
}

/* Force portrait layout when body has portrait class */
body.mobile.portrait #quickSlotsContainer {
    bottom: 10px !important;
    left: 10px !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    max-width: 254px !important;
    width: auto !important;
    padding: 6px 8px !important;
}

body.mobile.portrait #minimapContainer {
    bottom: 180px !important;
    right: 15px !important;
    left: auto !important;
    transform: none !important;
}

body.mobile.portrait #controls {
    bottom: 10px !important;
    right: 10px !important;
    left: auto !important;
}

body.mobile.portrait #locationInfo {
    display: block !important;
    top: 65px !important;
    bottom: auto !important;
}

/* Force landscape layout when body has landscape class */
body.mobile.landscape #quickSlotsContainer {
    bottom: 10px !important;
    left: 10px !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    flex-direction: column !important;
}

body.mobile.landscape #minimapContainer {
    bottom: 180px !important;
    right: 15px !important;
    left: auto !important;
    transform: none !important;
}

body.mobile.landscape #controls {
    bottom: 5px !important;
    right: 5px !important;
    left: auto !important;
}

body.mobile.landscape #statsContainer {
    top: 5px !important;
    left: 5px !important;
    right: auto !important;
}

body.mobile.landscape #locationInfo {
    top: 50px !important;
    left: 5px !important;
    display: block !important;
}

/* Extra small screens (phones) - even more compact */
@media (max-width: 480px) {
    /* Even smaller title */
    #titleContainer {
        padding: 5px 8px;
        min-width: 120px;
        font-size: 9px;
    }
    
    #titleContainer h3 {
        font-size: 12px;
    }
    
    /* Quote is already hidden from parent media query */
    
    /* Compact stats */
    #statsContainer {
        min-width: 220px; /* Doubled from 110px */
        max-width: 280px; /* Doubled from 140px */
        padding: 8px 6px; /* Doubled height: 4px -> 8px */
        font-size: 8px;
    }
    
    #statsContainer .stat-bar {
        height: 9px;
    }
    
    #statsContainer .stat-bar-text {
        font-size: 6px;
        line-height: 9px;
    }
    
    .level-display {
        margin-top: 4px;
        padding-top: 4px;
    }
    
    .level-text {
        font-size: 7px !important;
    }
    
    /* Smaller menu icons */
    .menu-icon {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }
    
    /* Quick slots - smaller */
    #quickSlotsContainer {
        bottom: 10px;
        top: auto;
        left: 10px;
        transform: none;
        padding: 4px 8px;
        gap: 3px;
        flex-direction: column;
        max-width: 90px;
    }
    
    .quick-slot {
        width: 36px;
        height: 36px;
        border-width: 2px;
        border-radius: 6px;
    }
    
    .quick-slot .slot-icon {
        font-size: 16px;
    }
    
    .quick-slot .slot-number {
        width: 12px;
        height: 12px;
        font-size: 7px;
        top: -6px;
        left: -6px;
    }
    
    /* Minimap container - smaller and on right side */
    #minimapContainer {
        bottom: 170px;
        right: 15px;
    }
    
    #minimapToggle {
        font-size: 9px;
        padding: 2px 5px;
        margin-bottom: 2px;
    }
    
    #minimap {
        width: 60px;
        height: 45px;
    }
    
    /* Controls - more compact */
    #controls {
        bottom: 10px;
        right: 10px;
        grid-template-columns: 40px 40px 40px;
        gap: 2px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* Location info - minimal */
    #locationInfo {
        top: 55px;
        left: 10px;
        max-width: 140px;
        padding: 5px;
        font-size: 8px;
    }
    
    #locationInfo h4 {
        font-size: 10px;
    }
    
    #locationInfo.collapsed {
        padding: 4px 6px;
    }
    
    /* Selection wheel */
    .selection-wheel {
        padding: 12px;
        max-height: 45vh;
    }
    
    .wheel-header {
        font-size: 13px;
        margin-bottom: 10px;
    }
    
    .wheel-nav {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .wheel-item {
        padding: 8px;
    }
    
    .wheel-item-icon {
        font-size: 20px;
        margin-bottom: 3px;
    }
    
    .wheel-item-name {
        font-size: 12px;
        margin-bottom: 1px;
    }
    
    .wheel-item-type {
        font-size: 9px;
    }
    
    .wheel-btn {
        padding: 8px 16px;
        font-size: 12px;
        min-height: 40px;
    }
}

/* Portrait orientation specific adjustments */
@media (max-width: 768px) and (orientation: portrait) {
    /* Keep existing portrait styles but ensure minimap is visible */
    #minimapContainer {
        bottom: 180px;
        right: 15px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    /* Adjust UI for landscape layout */
    #titleContainer {
        top: 3px;
        padding: 4px 8px;
        min-width: 120px;
    }
    
    #titleContainer h3 {
        font-size: 12px;
    }
    
    /* Quote already hidden from parent media query */
    
    /* Stats on the left side - more compact */
    #statsContainer {
        top: 5px;
        left: 5px;
        right: auto;
        max-width: 280px; /* Doubled from 140px */
        padding: 8px 6px; /* Doubled height: 4px -> 8px */
    }
    
    #statsContainer .stat-bar {
        height: 18px;
    }
    
    #statsContainer .stat-bar-text {
        font-size: 9px;
        line-height: 15px;
    }
    
    .level-display {
        margin-top: 5px;
        padding-top: 5px;
    }
    
    .level-text {
        font-size: 8px !important;
    }
    
    /* Location info below stats - compact */
    #locationInfo {
        top: 50px;
        left: 5px;
        right: auto;
        max-width: 140px;
        padding: 5px;
        font-size: 8px;
    }
    
    #locationInfo h4 {
        font-size: 10px;
    }
    
    /* Menu icons on the right */
    .menu-icons {
        top: 3px;
        right: 5px;
    }
    
    .menu-icon {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }
    
    /* Quick slots positioned at bottom left */
    #quickSlotsContainer {
        bottom: 10px;
        top: auto;
        left: 10px;
        right: auto;
        transform: none;
        flex-direction: column;
        padding: 4px 8px;
        max-width: 110px;
        width: auto;
    }
    
    .quick-slot {
        width: 36px;
        height: 36px;
        border-width: 2px;
        border-radius: 6px;
    }
    
    .quick-slot .slot-icon {
        font-size: 16px;
    }
    
    .quick-slot .slot-number {
        width: 12px;
        height: 12px;
        font-size: 7px;
        top: -6px;
        left: -6px;
    }
    
    /* Minimap container - positioned to avoid overlap */
    #minimapContainer {
        bottom: 170px;
        right: 15px;
        z-index: 20;
    }
    
    #minimapToggle {
        font-size: 8px;
        padding: 2px 4px;
        margin-bottom: 2px;
    }
    
    #minimap {
        width: 60px;
        height: 40px;
    }
    
    /* Controls on bottom right - compact */
    #controls {
        bottom: 5px;
        right: 5px;
        left: auto;
        transform: none;
        grid-template-columns: 38px 38px 38px;
        gap: 1px;
    }
    
    .control-btn {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
}

/* Stacked Notification System */
#notificationStack {
    position: fixed;
    top: 200px; /* well below quest tracker */
    right: 20px;
    left: 250px; /* avoid HP/MP/XP area */
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    pointer-events: none;
}

.stack-notification {
    min-width: unset;
    max-width: 300px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(170, 255, 119, 0.3);
    border-radius: 4px;
    color: #aaff77;
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: bold;
    padding: 4px 8px;
    margin-bottom: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s, transform 0.5s;
    pointer-events: none;
    white-space: nowrap;
    text-shadow: 0 1px 2px #000;
    letter-spacing: 0.3px;
    text-overflow: ellipsis;
    overflow: hidden;
}

.stack-notification.fade-out {
    opacity: 0;
    transform: translateY(-20px);
}

.stack-notification.type-item {
    color: #aaff77;
    border-color: rgba(170, 255, 119, 0.4);
    text-shadow: 0 1px 2px #000;
}

.stack-notification.type-quest {
    color: #ffe066;
    border-color: rgba(255, 224, 102, 0.4);
    text-shadow: 0 1px 2px #000;
}

.stack-notification.type-xp {
    color: #66ccff;
    border-color: rgba(102, 204, 255, 0.4);
    text-shadow: 0 1px 2px #000;
}

.stack-notification.type-system {
    color: #fffbe6;
    border-color: rgba(255, 251, 230, 0.4);
    text-shadow: 0 1px 2px #000;
}

.stack-notification.type-combat {
    color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.4);
    text-shadow: 0 1px 2px #000;
}


/* Bottom Event Ticker Bar */
#eventTicker {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    border-top: 1px solid rgba(212, 175, 55, 0.25);
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
    padding: 0 10px;
}

#eventTicker .ticker-msg {
    color: #c9a876;
    font-family: 'Cinzel', serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    opacity: 0;
    animation: ticker-in 0.3s ease forwards;
}

#eventTicker .ticker-msg.fade-out {
    animation: ticker-out 0.5s ease forwards;
}

@keyframes ticker-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ticker-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-5px); }
}

#eventTicker .ticker-msg.type-item { color: #aaff77; }
#eventTicker .ticker-msg.type-quest { color: #ffe066; }
#eventTicker .ticker-msg.type-xp { color: #66ccff; }
#eventTicker .ticker-msg.type-combat { color: #ff6b6b; }
#eventTicker .ticker-msg.type-system { color: #fffbe6; }
#eventTicker .ticker-msg.type-soul { color: #ba55d3; }
#eventTicker .ticker-msg.type-plant { color: #9333ea; }

/* Adjust joystick position on mobile to account for ticker */
@media (max-width: 768px) {
    #eventTicker {
        height: 24px;
        bottom: env(safe-area-inset-bottom, 0px);
    }

    #eventTicker .ticker-msg {
        font-size: 11px;
    }
}

/* Quest button persistent glow animation */
@keyframes quest-button-persistent-glow {
    0% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(212, 175, 55, 0.8), 0 0 20px rgba(212, 175, 55, 0.6), 0 0 30px rgba(212, 175, 55, 0.4);
        filter: brightness(1.2);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(212, 175, 55, 1), 0 0 25px rgba(212, 175, 55, 0.8), 0 0 35px rgba(212, 175, 55, 0.6);
        filter: brightness(1.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(212, 175, 55, 0.8), 0 0 20px rgba(212, 175, 55, 0.6), 0 0 30px rgba(212, 175, 55, 0.4);
        filter: brightness(1.2);
    }
}

/* Quest button glow class */
.quest-button-glow {
    position: relative;
    z-index: 10;
    border-color: #d4af37 !important;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.8), 0 0 25px rgba(212, 175, 55, 0.6), 0 0 35px rgba(212, 175, 55, 0.4) !important;
    animation: quest-button-persistent-glow 2s ease-in-out infinite !important;
    filter: brightness(1.2) !important;
}

.quest-button-glow::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
}

/* Override any conflicting transitions */
.menu-icon.quest-button-glow {
    transition: none !important;
}


/* Drag element styles */
.drag-item {
    position: fixed;
    background: rgba(20, 15, 10, 0.95);
    border: 2px solid #d4af37;
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
    transform: rotate(5deg);
    pointer-events: none;
    cursor: grabbing;
    z-index: 10001;
}

.drag-item-icon {
    font-size: 24px;
    text-align: center;
}

.drag-item-count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(212, 175, 55, 0.9);
    color: #2a1a0a;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 3px;
    min-width: 16px;
    text-align: center;
}

/* Inventory hover info tooltip */
#inventoryHoverInfo {
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #d4af37;
    border-radius: 5px;
    padding: 10px;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    transition: opacity 0.2s ease-in-out;
    z-index: 10001;
    min-width: 180px;
    max-width: 220px;
}

/* Virtual Joystick - REMOVED (using D-pad only) */

/* D-pad controls always visible on all devices */
@media (max-width: 768px) {
    #controls {
        display: grid !important;
    }
}

/* Welcome Overlay */
#welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(20, 15, 10, 0.95) 0%, 
        rgba(40, 30, 20, 0.98) 50%, 
        rgba(20, 15, 10, 0.95) 100%);
    backdrop-filter: blur(8px);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

#welcome-overlay.fade-out {
    opacity: 0;
}

.welcome-content {
    background: linear-gradient(145deg, 
        rgba(30, 25, 15, 0.95) 0%, 
        rgba(50, 40, 25, 0.98) 100%);
    border: 3px solid #d4af37;
    border-radius: 15px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 
        0 0 30px rgba(212, 175, 55, 0.3),
        0 10px 40px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: welcome-appear 0.8s ease-out;
    font-family: 'Cinzel', serif;
}

@keyframes welcome-appear {
    0% {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.welcome-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(212, 175, 55, 0.3);
}

.welcome-header h2 {
    color: #d4af37;
    font-size: 28px;
    margin: 0 0 10px 0;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
    letter-spacing: 1px;
}

.welcome-subtitle {
    color: #c9a876;
    font-size: 16px;
    margin: 0;
    font-style: italic;
    line-height: 1.4;
}

.welcome-sections {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin-bottom: 30px;
}

.welcome-section {
    background: rgba(20, 15, 10, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
}

.welcome-section:hover {
    background: rgba(20, 15, 10, 0.6);
    border-color: rgba(212, 175, 55, 0.4);
    transform: translateY(-2px);
}

.welcome-section h3 {
    color: #d4af37;
    font-size: 18px;
    margin: 0 0 15px 0;
    text-shadow: 0 0 5px rgba(212, 175, 55, 0.3);
}

.welcome-section p {
    color: #e8d7c3;
    font-size: 14px;
    line-height: 1.5;
    margin: 8px 0;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.control-item:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: rgba(212, 175, 55, 0.4);
}

.control-key {
    background: #d4af37;
    color: #2a1a0a;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    min-width: 40px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.control-desc {
    color: #e8d7c3;
    font-size: 13px;
    font-weight: 500;
}

.welcome-tips {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
}

.welcome-tips li {
    color: #e8d7c3;
    font-size: 14px;
    line-height: 1.5;
    margin: 8px 0;
    padding-left: 20px;
    position: relative;
}

.welcome-tips li::before {
    content: '✨';
    position: absolute;
    left: 0;
    top: 0;
    color: #d4af37;
    font-size: 12px;
}

.welcome-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 2px solid rgba(212, 175, 55, 0.3);
}

.welcome-btn {
    background: linear-gradient(145deg, #d4af37, #b8941f);
    color: #2a1a0a;
    border: none;
    border-radius: 8px;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: bold;
    font-family: 'Cinzel', serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.3),
        0 2px 4px rgba(212, 175, 55, 0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.welcome-btn:hover {
    background: linear-gradient(145deg, #e6c158, #d4af37);
    transform: translateY(-2px);
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.4),
        0 4px 8px rgba(212, 175, 55, 0.3);
}

.welcome-btn:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        0 1px 2px rgba(212, 175, 55, 0.2);
}

/* Mobile responsive design for welcome overlay */
@media (max-width: 768px) {
    .welcome-content {
        padding: 25px;
        margin: 20px;
        max-height: 85vh;
    }
    
    .welcome-header h2 {
        font-size: 24px;
    }
    
    .welcome-subtitle {
        font-size: 14px;
    }
    
    .welcome-section {
        padding: 15px;
    }
    
    .welcome-section h3 {
        font-size: 16px;
    }
    
    .control-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .control-item {
        padding: 6px 8px;
    }
    
    .control-key {
        font-size: 11px;
        min-width: 35px;
    }
    
    .control-desc {
        font-size: 12px;
    }
    
    .welcome-tips li {
        font-size: 13px;
    }
    
    .welcome-btn {
        padding: 12px 25px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .welcome-content {
        padding: 20px;
        margin: 15px;
    }
    
    .welcome-header h2 {
        font-size: 20px;
    }
    
    .welcome-subtitle {
        font-size: 13px;
    }
    
    .welcome-sections {
        gap: 20px;
    }
    
    .welcome-section {
        padding: 12px;
    }
    
    .control-grid {
        grid-template-columns: 1fr;
    }
    
    .welcome-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* NPC Chat System - Matching Orb Fairy Style */
.npc-chat-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    height: 70%;
    max-height: 600px;
    background: rgba(15, 25, 15, 0.95);
    border: 2px solid #8b7355;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(139, 115, 85, 0.4);
    display: flex;
    flex-direction: column;
    z-index: 2000;
    font-family: 'Crimson Text', serif;
    backdrop-filter: blur(10px);
}

.npc-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #4a3a2a;
    background: rgba(20, 15, 10, 0.8);
    border-radius: 10px 10px 0 0;
}

.npc-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d4af37;
    font-size: 16px;
    font-weight: 600;
}

.npc-icon {
    font-size: 20px;
    animation: npc-glow 2s ease-in-out infinite alternate;
}

@keyframes npc-glow {
    0% { text-shadow: 0 0 5px rgba(212, 175, 55, 0.5); }
    100% { text-shadow: 0 0 15px rgba(212, 175, 55, 0.8), 0 0 25px rgba(255, 255, 200, 0.3); }
}

.npc-chat-close {
    background: none;
    border: none;
    color: #8b7355;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
}

.npc-chat-close:hover {
    color: #d4af37;
    background: rgba(212, 175, 55, 0.1);
}

.npc-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.npc-chat-message {
    display: flex;
    margin-bottom: 10px;
}

.npc-chat-message.user-message {
    justify-content: flex-end;
}

.npc-chat-message.npc-message {
    justify-content: flex-start;
}

.npc-chat-message-content {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 12px;
    position: relative;
}

.user-message .npc-chat-message-content {
    background: rgba(139, 115, 85, 0.3);
    border: 1px solid #8b7355;
    color: #e8ddc3;
}

.npc-message .npc-chat-message-content {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid #d4af37;
    color: #c9a876;
}

.npc-chat-message-text {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 5px;
}

.npc-chat-message-time {
    font-size: 11px;
    opacity: 0.6;
    text-align: right;
}

.npc-chat-input-area {
    padding: 15px;
    border-top: 1px solid #4a3a2a;
    background: rgba(20, 15, 10, 0.8);
    border-radius: 0 0 10px 10px;
}

.npc-dialogue-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.npc-dialogue-option {
    background: rgba(139, 115, 85, 0.8);
    border: 1px solid #8b7355;
    border-radius: 20px;
    padding: 6px 12px;
    color: #e8ddc3;
    font-family: 'Crimson Text', serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.npc-dialogue-option:hover {
    background: rgba(139, 115, 85, 1);
    border-color: #d4af37;
    transform: translateY(-1px);
}

.npc-dialogue-option:active {
    transform: translateY(0);
}

.npc-chat-input-controls {
    display: flex;
    gap: 10px;
}

.npc-chat-input {
    flex: 1;
    background: rgba(15, 25, 15, 0.8);
    border: 1px solid #8b7355;
    border-radius: 6px;
    padding: 10px 12px;
    color: #e8ddc3;
    font-family: 'Crimson Text', serif;
    font-size: 14px;
}

.npc-chat-input:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.npc-chat-send {
    background: rgba(139, 115, 85, 0.3);
    border: 1px solid #8b7355;
    border-radius: 6px;
    padding: 10px 15px;
    color: #e8ddc3;
    cursor: pointer;
    font-family: 'Crimson Text', serif;
    font-size: 14px;
    transition: all 0.2s;
}

.npc-chat-send:hover {
    background: rgba(139, 115, 85, 0.5);
    border-color: #d4af37;
}

.loading-dots {
    display: inline-block;
    position: relative;
}

.loading-dots::after {
    content: '';
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Mobile responsive design for NPC chat */
@media (max-width: 768px) {
    .npc-chat-container {
        width: 95%;
        height: 80%;
        max-height: 500px;
    }
    
    .npc-chat-message-content {
        max-width: 90%;
    }
    
    .npc-chat-input-area {
        padding: 12px;
    }
    
    .npc-chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .npc-chat-send {
        padding: 12px 15px;
        font-size: 16px;
    }
}

@media (max-width: 768px) {
    
    .action-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .npc-chat-container {
        width: 98%;
        height: 85%;
        max-height: 450px;
    }
    
    .npc-chat-header {
        padding: 12px 15px;
    }
    
    .npc-chat-title {
        font-size: 14px;
    }
    
    .npc-icon {
        font-size: 18px;
    }
    
    .npc-chat-messages {
        padding: 12px;
    }
    
    .npc-chat-message-text {
        font-size: 13px;
    }
    
    .npc-chat-input-area {
        padding: 10px;
    }
}


.stat-number {
    font-size: 20px;
    font-weight: bold;
    font-family: 'Cinzel', serif;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}


/* ============================================
   ENHANCED MOBILE UX - iPhone Pro Max Optimized
   ============================================ */

/* iPhone-optimized stat bars - readable but compact */
@media (max-width: 768px) {
    #statsContainer {
        min-width: 180px !important;
        max-width: 220px !important;
        padding: 8px 10px !important;
        border-radius: 10px !important;
        top: env(safe-area-inset-top, 10px) !important;
        left: 10px !important;
    }

    #statsContainer .stat-bar {
        height: 20px !important;
        border-radius: 6px !important;
    }

    #statsContainer .stat-bar-text {
        font-size: 12px !important;
        line-height: 20px !important;
    }

    #statsContainer .stat-label {
        font-size: 12px !important;
        min-width: 24px !important;
        margin-right: 6px !important;
    }

    #statsContainer .stat-bar-container {
        margin: 3px 0 !important;
        gap: 4px !important;
    }

    .level-display {
        margin-top: 4px !important;
        padding-top: 4px !important;
    }

    .level-text {
        font-size: 10px !important;
    }

    /* Currency tracker compact */
    #currencyTracker {
        margin-top: 4px !important;
        padding: 3px 4px !important;
    }

    .currency-icon-sm {
        font-size: 12px !important;
    }

    .currency-val {
        font-size: 11px !important;
    }

    #zoneDisplay {
        font-size: 10px !important;
        margin-top: 3px !important;
    }
}

/* Joystick on LEFT side for left-thumb ergonomics */
@media (max-width: 768px) {
    #joystickZone {
        left: 15px !important;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        z-index: 100 !important;
    }
}

/* Action buttons on RIGHT side for right-thumb ergonomics */
@media (max-width: 768px) {
    body.game-active .mobile-action-buttons {
        position: fixed !important;
        bottom: calc(30px + env(safe-area-inset-bottom, 0px)) !important;
        right: 15px !important;
        left: auto !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        z-index: 100 !important;
    }

    .mobile-action-buttons .action-btn {
        width: 72px !important;
        height: 72px !important;
        border-radius: 50% !important;
        border-width: 2px !important;
    }

    .mobile-action-buttons .action-icon {
        font-size: 28px !important;
    }

    .mobile-action-buttons .action-text {
        font-size: 8px !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
    }

    .mobile-action-buttons .interact-btn {
        background: rgba(212, 175, 55, 0.9) !important;
        border-color: #d4af37 !important;
        box-shadow: 0 0 20px rgba(212, 175, 55, 0.4) !important;
    }

    .mobile-action-buttons .attack-btn {
        background: rgba(220, 75, 75, 0.9) !important;
        border-color: #dc4b4b !important;
        box-shadow: 0 0 20px rgba(220, 75, 75, 0.4) !important;
    }
}

/* Hide location info on mobile - too cluttered */
@media (max-width: 768px) {
    #locationInfo {
        display: none !important;
    }
}

/* Title container - more compact, stays out of the way */
@media (max-width: 768px) {
    #titleContainer {
        top: env(safe-area-inset-top, 5px) !important;
        padding: 4px 12px !important;
        height: 26px !important;
        border-radius: 6px !important;
        border-width: 1px !important;
    }

    #titleContainer h3 {
        font-size: 12px !important;
    }
}

/* Menu icons - larger touch targets */
@media (max-width: 768px) {
    .menu-icons {
        top: env(safe-area-inset-top, 5px) !important;
        right: 10px !important;
        gap: 8px !important;
        z-index: 100 !important;
    }

    .menu-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
        border-radius: 10px !important;
        border-width: 2px !important;
    }
}

/* Quest tracker - mobile optimized below menu icons */
@media (max-width: 768px) {
    .quest-tracker {
        top: calc(env(safe-area-inset-top, 5px) + 50px) !important;
        right: 10px !important;
        width: 200px !important;
        min-height: auto !important;
        border-width: 1px !important;
        padding: 0 !important;
    }

    .quest-tracker-content {
        padding: 8px 10px !important;
    }

    .quest-tracker-title {
        font-size: 11px !important;
    }

    .objective-text {
        font-size: 10px !important;
    }

    .objective-progress {
        font-size: 9px !important;
    }
}

/* Quick slots - hide on mobile (replaced by action buttons) */
@media (max-width: 768px) {
    #quickSlotsContainer {
        display: none !important;
    }
}

/* Minimap - bottom left above D-pad */
@media (max-width: 768px) {
    #minimapContainer {
        position: fixed !important;
        bottom: calc(200px + env(safe-area-inset-bottom, 0px)) !important;
        left: 15px !important;
        right: auto !important;
        z-index: 50 !important;
    }

    #minimap {
        width: 80px !important;
        height: 55px !important;
        border-radius: 8px !important;
    }

    #minimapToggle {
        font-size: 12px !important;
        padding: 4px 8px !important;
        border-radius: 8px !important;
    }
}

/* Panel modals - full screen on mobile for usability */
@media (max-width: 768px) {
    .menu-panel {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        min-width: auto !important;
        width: 100vw !important;
        border-radius: 0 !important;
        padding: 20px !important;
        padding-top: calc(20px + env(safe-area-inset-top, 0px)) !important;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        transform: none !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .menu-panel.show {
        transform: none !important;
    }

    .menu-panel .close-btn {
        top: calc(10px + env(safe-area-inset-top, 0px)) !important;
        right: 15px !important;
        width: 36px !important;
        height: 36px !important;
        font-size: 24px !important;
        line-height: 36px !important;
        text-align: center !important;
        background: rgba(139, 115, 85, 0.2) !important;
        border-radius: 50% !important;
    }

    #craftingPanel {
        min-width: auto !important;
        min-height: auto !important;
    }

    #questPanel {
        min-height: auto !important;
    }

    #inventoryGrid {
        min-width: auto !important;
    }

    .inventory-grid {
        grid-template-columns: repeat(7, 44px) !important;
        grid-gap: 4px !important;
        justify-content: center !important;
    }

    .inventory-slot {
        width: 44px !important;
        height: 44px !important;
    }
}

/* Notification stack - centered on mobile, not overlapping controls */
@media (max-width: 768px) {
    #notificationStack {
        top: auto !important;
        bottom: calc(220px + env(safe-area-inset-bottom, 0px)) !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        align-items: center !important;
        max-width: 85vw !important;
    }

    .stack-notification {
        max-width: 85vw !important;
        font-size: 12px !important;
        white-space: normal !important;
        text-align: center !important;
    }
}

/* Welcome screen - mobile touch instructions */
@media (max-width: 768px) {
    #focusHelper {
        min-width: auto !important;
        max-width: 88vw !important;
        max-height: none !important;
        border-radius: 16px !important;
        overflow-y: visible !important;
    }

    #focusHelper .welcome-content {
        padding: 20px 18px !important;
    }

    #focusHelper .welcome-header h2 {
        font-size: 24px !important;
        margin-bottom: 8px !important;
    }

    #focusHelper .welcome-quote {
        font-size: 14px !important;
        margin-bottom: 14px !important;
    }

    /* Hide full paragraphs, show condensed mobile version */
    .story-paragraph-full {
        display: none !important;
    }
    .story-paragraph-mobile {
        display: block !important;
    }

    .mobile-first-quest {
        margin-bottom: 4px !important;
        padding: 8px 12px !important;
    }

    .mobile-first-quest-title {
        font-size: 13px !important;
    }

    .mobile-first-quest-desc {
        font-size: 11px !important;
    }

    #focusHelper .welcome-footer {
        margin-top: 14px !important;
    }

    /* Show mobile-specific controls hint */
    .controls-hint-desktop {
        display: none !important;
    }
    .controls-hint-mobile {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .controls-hint-desktop {
        display: block !important;
    }
    .controls-hint-mobile {
        display: none !important;
    }
    .story-paragraph-full {
        display: block !important;
    }
    .story-paragraph-mobile {
        display: none !important;
    }
}

/* Override body.mobile.portrait joystick positioning */
body.mobile.portrait #joystickZone {
    left: 15px !important;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
}

body.mobile.landscape #joystickZone {
    left: 15px !important;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Override quick slots hiding for mobile */
body.mobile #quickSlotsContainer {
    display: none !important;
}

/* Plant/Seed mobile quick action button - hidden for now (planting de-emphasized) */
.mobile-plant-btn {
    display: none !important;
}

/* Landscape specific adjustments for large phones */
@media (max-width: 768px) and (orientation: landscape) {
    #statsContainer {
        max-width: 200px !important;
        padding: 6px 8px !important;
    }

    #statsContainer .stat-bar {
        height: 16px !important;
    }

    #statsContainer .stat-bar-text {
        font-size: 10px !important;
        line-height: 16px !important;
    }

    #joystickZone {
        width: 120px !important;
        height: 120px !important;
        bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    }

    #joystickBase {
        width: 100px !important;
        height: 100px !important;
    }

    #joystickKnob {
        width: 40px !important;
        height: 40px !important;
    }

    .mobile-action-buttons {
        bottom: calc(15px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .mobile-action-buttons .action-btn {
        width: 60px !important;
        height: 60px !important;
    }
}

/* Enhanced quest tracker - with hint display */
.quest-tracker-hint {
    font-size: 10px;
    color: #c9a876;
    font-style: italic;
    margin-top: 4px;
    line-height: 1.3;
    opacity: 0.85;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.quest-tracker-next-step {
    font-size: 10px;
    color: #8fbc8f;
    margin-top: 4px;
    padding: 3px 6px;
    background: rgba(143, 188, 143, 0.08);
    border-radius: 4px;
    border-left: 2px solid rgba(143, 188, 143, 0.3);
}

/* Welcome screen - Mobile first quest intro */
.mobile-first-quest {
    margin-top: 16px;
    padding: 12px;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 8px;
    text-align: center;
}

.mobile-first-quest-title {
    color: #d4af37;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.mobile-first-quest-desc {
    color: #c9a876;
    font-size: 11px;
    line-height: 1.4;
}


/* ===== Bestiary Panel ===== */
#bestiaryPanel {
    min-width: 420px;
    max-width: 480px;
    overflow-y: auto;
}

.bestiary-progress {
    color: #c9a876;
    font-size: 14px;
    margin-bottom: 12px;
    text-align: center;
    letter-spacing: 1px;
    font-family: 'Cinzel', serif;
}

.bestiary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.bestiary-card {
    position: relative;
    background: rgba(20, 15, 10, 0.9);
    border: 1px solid #8b7355;
    border-radius: 6px;
    padding: 10px 6px 8px;
    text-align: center;
    transition: all 0.2s ease;
}

.bestiary-card.known {
    cursor: pointer;
}

.bestiary-card.known:hover {
    border-color: #d4af37;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.35);
    transform: translateY(-1px);
}

.bestiary-card.unknown {
    opacity: 0.55;
}

.bestiary-card.unknown .bestiary-icon {
    filter: brightness(0);
}

.bestiary-icon {
    font-size: 26px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bestiary-icon canvas {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.bestiary-name {
    font-family: 'Cinzel', serif;
    font-size: 12px;
    color: #e8dcc8;
    margin-top: 6px;
}

.bestiary-kills {
    font-size: 11px;
    color: #c9a876;
    margin-top: 2px;
}

.bestiary-boss-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(212, 175, 55, 0.15);
    color: #d4af37;
    border: 1px solid #d4af37;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: 'Cinzel', serif;
    letter-spacing: 1px;
}

.bestiary-boss-badge.inline {
    position: static;
    margin-left: 6px;
    vertical-align: middle;
}

.bestiary-back {
    background: none;
    border: 1px solid #8b7355;
    color: #c9a876;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Crimson Text', serif;
    font-size: 13px;
    margin-bottom: 12px;
}

.bestiary-back:hover {
    border-color: #d4af37;
    color: #d4af37;
}

.bestiary-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.bestiary-detail-icon {
    font-size: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bestiary-detail-icon canvas {
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
}

.bestiary-detail-title {
    font-family: 'Cinzel', serif;
    color: #d4af37;
    font-size: 18px;
}

.bestiary-detail-sub {
    color: #c9a876;
    font-size: 13px;
}

.bestiary-stats {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}

.bestiary-stats td {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(139, 115, 85, 0.3);
    font-size: 13px;
}

.bestiary-stats td:first-child {
    color: #8b9b8b;
}

.bestiary-stats td:last-child {
    color: #e8dcc8;
    text-align: right;
}

.bestiary-drops-title {
    font-family: 'Cinzel', serif;
    color: #d4af37;
    font-size: 14px;
    margin-bottom: 6px;
}

.bestiary-drop-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 13px;
}

.bestiary-drop-name {
    flex: 1;
}

.bestiary-drop-chance {
    color: #8b9b8b;
    font-size: 12px;
}

/* Lantern Rest intro sequence (new game only) */
#introOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    z-index: 10000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 1.2s ease-in-out;
}

#introOverlay.intro-visible {
    display: flex;
}

#introOverlay.intro-fade-out {
    opacity: 0;
}

#introOverlay .intro-lines {
    max-width: 700px;
}

#introOverlay .intro-line {
    font-family: 'Cinzel', serif;
    color: #d4af37;
    font-size: 22px;
    line-height: 1.8;
    letter-spacing: 0.5px;
    margin: 12px 0;
    opacity: 0;
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
    animation: intro-line-fade 1.5s ease-out forwards;
}

#introOverlay .intro-line:nth-child(1) { animation-delay: 0.3s; }
#introOverlay .intro-line:nth-child(2) { animation-delay: 2.3s; }
#introOverlay .intro-line:nth-child(3) { animation-delay: 4.3s; }

@keyframes intro-line-fade {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

#introOverlay .intro-hint {
    margin-top: 40px;
    font-family: 'Crimson Text', serif;
    font-style: italic;
    color: #8b7355;
    font-size: 14px;
    letter-spacing: 1px;
    opacity: 0;
    animation: intro-line-fade 1.5s ease-out forwards;
    animation-delay: 6.5s;
}

@media (max-width: 768px) {
    #introOverlay .intro-line {
        font-size: 16px;
    }
}

/* ============================================================
   QUEST LOG UI (js/ui/QuestLogUI.js) - two-tab Quest Log panel.
   All rules in this block use a `.qlog-` prefix and are exclusive
   to this component; nothing outside this file references them.
   ============================================================ */

#questLogRoot {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* ---- Tab bar ---- */

.qlog-tabbar {
    display: flex;
    flex-shrink: 0;
    gap: 0;
    margin: 4px 0 16px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #8b7355;
}

.qlog-tab {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(139, 115, 85, 0.12);
    border: none;
    border-right: 1px solid rgba(139, 115, 85, 0.5);
    color: #c9a876;
    padding: 12px 16px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.4px;
    transition: background 0.2s ease, color 0.2s ease;
}

.qlog-tab:last-child {
    border-right: none;
}

.qlog-tab:hover {
    background: rgba(139, 115, 85, 0.22);
    color: #e8d7c3;
}

.qlog-tab--active {
    background: rgba(212, 175, 55, 0.2);
    color: #d4af37;
    box-shadow: inset 0 -2px 0 #d4af37;
}

.qlog-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    font-family: 'Crimson Text', serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* The `hidden` attribute is how QuestLogUI toggles these badges; without
   this, `display: inline-flex` above would win the cascade (equal
   specificity to the UA [hidden] rule, declared later) and the badge would
   stay visible - e.g. showing "0" on the Side Quests tab. */
.qlog-tab-badge[hidden] {
    display: none;
}

.qlog-tab-badge-bang {
    background: #d4af37;
    color: #2a1f0f;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.7);
}

.qlog-tab-badge-count {
    background: rgba(154, 205, 50, 0.25);
    color: #9acd32;
    border: 1px solid rgba(154, 205, 50, 0.5);
}

/* ---- Body / view switching ---- */

.qlog-body {
    position: relative;
    flex: 1;
    min-height: 0;
}

.qlog-view {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
}

.qlog-view--active {
    display: block;
}

.qlog-view::-webkit-scrollbar {
    width: 8px;
}

.qlog-view::-webkit-scrollbar-track {
    background: rgba(139, 115, 85, 0.1);
    border-radius: 4px;
}

.qlog-view::-webkit-scrollbar-thumb {
    background: rgba(139, 115, 85, 0.4);
    border-radius: 4px;
}

/* ---- Main tab: chapter timeline ---- */

.qlog-timeline {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 8px;
}

.qlog-chapter {
    border-radius: 10px;
    border: 1px solid rgba(139, 115, 85, 0.35);
    background: linear-gradient(135deg, rgba(20, 15, 10, 0.9), rgba(40, 30, 20, 0.75));
}

.qlog-chapter--completed,
.qlog-chapter--locked {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
}

.qlog-chapter--completed {
    opacity: 0.65;
    border-color: rgba(154, 205, 50, 0.35);
}

.qlog-chapter--locked {
    background: rgba(10, 8, 6, 0.75);
    border-color: rgba(80, 70, 60, 0.4);
    opacity: 0.55;
}

.qlog-chapter--current {
    padding: 16px 18px;
    border-color: #d4af37;
    box-shadow: 0 0 24px rgba(212, 175, 55, 0.18), inset 0 0 0 1px rgba(212, 175, 55, 0.08);
}

.qlog-chapter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.qlog-medallion {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 700;
    border: 1.5px solid #8b7355;
    color: #c9a876;
    background: rgba(0, 0, 0, 0.3);
}

.qlog-medallion--current {
    border-color: #d4af37;
    color: #ffd700;
    background: rgba(212, 175, 55, 0.15);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.qlog-medallion--completed {
    border-color: #9acd32;
    color: #9acd32;
    background: rgba(154, 205, 50, 0.12);
}

.qlog-chapter-title {
    flex: 1;
    font-family: 'Cinzel', serif;
    font-size: 14px;
    color: #e8d7c3;
    letter-spacing: 0.2px;
}

.qlog-chapter--current .qlog-chapter-title {
    font-size: 17px;
    color: #d4af37;
    text-shadow: 0 0 6px rgba(212, 175, 55, 0.5);
}

.qlog-chapter-check {
    flex-shrink: 0;
    color: #9acd32;
    font-size: 16px;
    font-weight: 700;
}

.qlog-lock-glyph {
    flex-shrink: 0;
    font-size: 15px;
    filter: grayscale(1);
}

.qlog-chapter-desc {
    font-family: 'Crimson Text', serif;
    font-style: italic;
    font-size: 13.5px;
    line-height: 1.55;
    color: #d8c9b3;
    margin-bottom: 14px;
}

.qlog-turnin-banner {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.25), rgba(212, 175, 55, 0.08));
    border: 1px solid #d4af37;
    color: #ffd700;
    font-family: 'Cinzel', serif;
    font-size: 13px;
    text-align: center;
    letter-spacing: 0.3px;
}

/* ---- Shared: objectives + rewards (both tabs) ---- */

.qlog-objectives {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.qlog-objective {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 12px;
    row-gap: 6px;
    align-items: center;
}

.qlog-objective-text {
    grid-column: 1 / -1;
    font-family: 'Crimson Text', serif;
    font-size: 13px;
    color: #e8d7c3;
    line-height: 1.4;
}

.qlog-objective--complete .qlog-objective-text {
    color: #b7d98c;
}

.qlog-progress-track {
    height: 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(139, 115, 85, 0.3);
    overflow: hidden;
}

.qlog-progress-fill {
    height: 100%;
    min-width: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, #d4af37, #9acd32);
    transition: width 0.4s ease;
}

.qlog-objective-count {
    grid-column: 2;
    grid-row: 2;
    font-family: 'Crimson Text', serif;
    font-size: 11.5px;
    font-weight: 600;
    color: #c9a876;
    white-space: nowrap;
}

.qlog-objective:not(.qlog-objective--complete) .qlog-objective-count {
    color: #d4af37;
}

.qlog-objective--complete .qlog-objective-count {
    color: #9acd32;
}

.qlog-rewards {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.qlog-reward {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.25);
    font-family: 'Crimson Text', serif;
    font-size: 11.5px;
    color: #e8d7c3;
    white-space: nowrap;
}

/* ---- Side tab ---- */

.qlog-side-active {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.qlog-card {
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid rgba(139, 115, 85, 0.35);
    background: linear-gradient(135deg, rgba(20, 15, 10, 0.9), rgba(40, 30, 20, 0.75));
}

.qlog-card--stub {
    opacity: 0.55;
    border-style: dashed;
    background: rgba(10, 8, 6, 0.6);
}

.qlog-card-title {
    font-family: 'Cinzel', serif;
    font-size: 15px;
    color: #d4af37;
    margin-bottom: 10px;
}

.qlog-card-title--mystery {
    color: #8b7355;
    font-style: italic;
    letter-spacing: 2px;
    margin-bottom: 0;
}

.qlog-chain-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(139, 115, 85, 0.3);
}

.qlog-chain-name {
    font-family: 'Crimson Text', serif;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #a67c52;
}

.qlog-chain-pips {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.qlog-pip {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid #8b7355;
}

.qlog-pip--filled {
    background: #d4af37;
    border-color: #d4af37;
    box-shadow: 0 0 4px rgba(212, 175, 55, 0.7);
}

.qlog-side-completed {
    border-top: 1px solid rgba(139, 115, 85, 0.3);
    padding-top: 10px;
}

.qlog-completed-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 2px;
    font-family: 'Cinzel', serif;
    font-size: 12.5px;
    letter-spacing: 0.4px;
    color: #9acd32;
}

.qlog-completed-caret {
    color: #8b7355;
}

.qlog-completed-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.qlog-completed-list--collapsed {
    display: none;
}

.qlog-compact-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(154, 205, 50, 0.05);
    opacity: 0.75;
}

.qlog-compact-check {
    color: #9acd32;
    font-size: 12px;
    font-weight: 700;
}

.qlog-compact-title {
    font-family: 'Crimson Text', serif;
    font-size: 12.5px;
    color: #d8c9b3;
}

/* ---- Empty states ---- */

.qlog-empty {
    font-family: 'Crimson Text', serif;
    font-style: italic;
    font-size: 13.5px;
    color: #8b7355;
    text-align: center;
    padding: 30px 10px;
}

/* ---- Responsive: full-screen panel, pinned tabs, single-column cards ---- */

@media (max-width: 768px) {
    #questPanel {
        top: 0;
        left: 0;
        transform: none;
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        border-width: 0;
        padding: 16px 14px;
    }

    .qlog-tabbar {
        margin-top: 36px; /* clear the close button */
    }

    .qlog-chapter--current,
    .qlog-card {
        padding: 14px;
    }

    .qlog-chapter-title {
        font-size: 13px;
    }

    .qlog-chapter--current .qlog-chapter-title {
        font-size: 15px;
    }
}
