:root {
    --bg-dark: #0a0b10;
    /* Deep Abyss */
    --bg-panel: #1c1e26;
    /* Dark Stone */
    --bg-hover: #2a2d3a;
    --accent-primary: #d4af37;
    /* Ancient Gold */
    --accent-secondary: #a61a1a;
    /* Imperial Crimson */
    --accent-bronze: #cd7f32;
    --text-main: #f4ecd8;
    /* Aged Parchment */
    --text-muted: #c0b59f;
    --border-color: #3e3a32;
    /* Weathered Bronze/Stone */
    --danger: #e74c3c;
    --success: #2ecc71;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Lustria', serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Prevent text selection on interactive game elements only */
#rock, #mobile-nav, .mobile-nav-btn, .tab-btn, .item-card,
.upgrade-icon-container, .zone-card, .equipment-slot,
.inventory-slot, .action-btn, .sub-nav-btn, .buy-mode-btn,
#upgrades-bar, #travel-corridor, #combat-action-bar,
#combat-end-actions, .battle-avatar, .stat-btn {
    user-select: none;
    -webkit-user-select: none;
}

/* Explicitly allow selection where it's useful */
textarea, input[type="text"], input[type="email"],
#save-data-field, #gift-code-input, #combat-log,
.tooltip-desc, .item-desc, .zone-lore {
    user-select: text;
    -webkit-user-select: text;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    /* Prevent scrolling */
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    display: grid;
    grid-template-columns: 1fr 520px;
    grid-template-rows: 1fr;
    width: 100%;
    height: 100%;
    /* max-width removed for 100% width */
}

/* Header */
/* Bottom Resource Bar */


.resource-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.resource-label {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

.resource-value {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--text-main);
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

/* Main Mining Stage */
#main-stage {
    grid-column: 1 / 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    background: radial-gradient(circle at center, #1e2235 0%, #0f111a 70%);
    padding-bottom: 60px;
    /* Space for bottom bar */
}

#click-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

#rock-container {
    width: clamp(200px, 25vw, 320px);
    height: clamp(200px, 25vw, 320px);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s;
}

#rock-container:active {
    transform: scale(0.95);
}

#rock {
    width: 100%;
    height: 100%;
    /* background-color: #636e72; Removed for image */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 50%;
    /* Box shadow can stay for extra pop, or be removed if it conflicts with pixel art */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    /* Ensures scaling stays within circle */
    transition: all 0.2s ease;
}

.rock-face {
    display: none;
    /* Hidden, replaced by images */
}

#rock:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.3);
}

/* Rock animation when clicked */
.hit {
    animation: shake 0.2s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

#rock-health-bar {
    width: clamp(200px, 30vw, 380px);
    height: 12px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid var(--accent-bronze);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.8);
}

#rock-health-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--accent-secondary), #600);
    box-shadow: 0 0 10px rgba(166, 26, 26, 0.5);
    transition: width 0.2s ease;
}

#rock-info {
    color: var(--text-muted);
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 10px;
    letter-spacing: 1px;
}

#rock-hp,
#rock-max-hp {
    color: var(--text-main);
    font-weight: 800;
}

/* Sidebar */
#sidebar {
    grid-column: 2 / 3;
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    width: 520px;
    /* Fixed width for better control */
    overflow: hidden;
    position: relative;
    /* Contain ancient pillars */
}

#tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    position: relative;
    flex: 1;
    padding: 15px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-hover);
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    background-color: rgba(212, 175, 55, 0.05);
}

/* --- Tab Badge / Notification Dots --- */
.tab-btn .nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 900;
    font-family: var(--font-heading);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    pointer-events: none;
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.8);
    animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}

.nav-badge.hidden {
    display: none;
}

@keyframes badgePop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

#tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* Unify scrolling to the entire column */
    display: flex;
    flex-direction: column;
}

/* Bulk Buy Controls */
/* Buy Mode Switcher Styles (Shared) */
.buy-mode-switcher {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    background: var(--bg-panel);
    padding: 8px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}


.buy-mode-btn {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    font-family: inherit;
}

.buy-mode-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.buy-mode-btn.active {
    background: var(--accent-primary);
    color: #000;
    font-weight: 900;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.panel {
    display: none;
    flex-direction: column;
    gap: 10px;
    height: auto;
    /* Let parent handle scrolling */
    min-height: 100%;
    overflow: visible;
    padding: 10px;
}

.panel.active {
    display: flex;
}

/* Upgrades Bar */
#upgrades-bar {
    position: absolute;
    top: 20px;
    width: 90%;
    max-width: 800px;
    /* Removed fixed height, added constraints */
    max-height: 120px;
    min-height: 60px;
    /* At least one row */
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow-y: auto;
    /* Scroll only if needed */
    backdrop-filter: blur(5px);
    z-index: 5;
    transition: all 0.2s ease;
}

.upgrade-icon-container {
    width: 48px;
    height: 48px;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    transition: all 0.2s;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.upgrade-icon-container.disabled {
    filter: grayscale(1) opacity(0.5);
    cursor: not-allowed;
}

.upgrade-icon-container:hover:not(.disabled) {
    border-color: var(--accent-secondary);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(0, 206, 201, 0.3);
}

.upgrade-icon-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}

/* Global Tooltip */
.tooltip {
    position: absolute;
    background-color: #111;
    border: 2px solid var(--accent-bronze);
    padding: 12px;
    border-radius: 2px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9), inset 0 0 20px rgba(212, 175, 55, 0.05);
    z-index: 9999;
    width: 340px;
}

.tooltip.active {
    opacity: 1;
    visibility: visible;
}

.tooltip .action-btn,
#game-tooltip .action-btn {
    width: 100% !important;
    white-space: normal !important;
    word-break: break-word !important;
    height: auto !important;
    padding: 8px 12px !important;
    line-height: 1.3 !important;
    box-sizing: border-box !important;
}

#game-tooltip {
    overflow-x: hidden;
}

.tooltip-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent-secondary);
    margin-bottom: 4px;
    display: block;
}

.tooltip-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: block;
    line-height: 1.2;
}

.tooltip-cost {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    display: block;
    text-align: right;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 4px;
}

/* Cards (Buildings) - Adjusted to be just building cards now */
.item-card {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 15px;
}

.item-icon {
    width: 70px;
    height: 70px;
    border-radius: 6px;
    background-color: rgba(0, 0, 0, 0.3);
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.item-card:hover:not(.disabled) {
    background-color: var(--bg-hover);
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.item-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.item-info {
    display: flex;
    flex-direction: column;
}

.item-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.item-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.item-cost {
    font-weight: 600;
    color: var(--accent-secondary);
    font-size: 0.9rem;
    text-align: right;
}

.cost-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
}

/* Floating Text */
#floating-text-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 100;
}

.floating-text {
    position: absolute;
    font-weight: 800;
    font-size: 1.5rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px) scale(1.2);
        opacity: 0;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}


.item-icon-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    border: 1px solid var(--border-color);
}

/* Offline Progress Modal & Custom Alerts */
#modal-overlay,
.modal-overlay,
#confirmation-modal,
#alert-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 30000;
    backdrop-filter: blur(5px);
}

#modal-overlay.active,
.modal-overlay.active,
#confirmation-modal.active,
#alert-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

#modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--accent-primary);
    padding: 0px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 0 50px rgba(108, 92, 231, 0.2);
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#modal-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent-secondary);
    margin-bottom: 15px;
}

#modal-body {
    color: var(--text-muted);
    margin-bottom: 25px;
    font-size: 1rem;
    line-height: 1.5;
}

#modal-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

#modal-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4);
}

/* Generic Modal Buttons */
.modal-btn {
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.modal-btn:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
}

.modal-btn.cancel:hover {
    background: #3a3d4a !important;
    color: #fff !important;
}

.modal-btn.confirm:hover {
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.4);
}

/* Story Modal Overhaul (v2.43.0) */
#story-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.story-container {
    max-width: 650px;
    width: 90%;
    background: rgba(10, 15, 25, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(212, 175, 55, 0.05);
    position: relative;
    animation: storySlideUp 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@keyframes storySlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.story-header {
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.story-portrait {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.story-meta {
    flex: 1;
}

.story-char-name {
    font-family: var(--font-heading);
    color: var(--accent-primary);
    font-size: 0.8rem;
    letter-spacing: 2px;
    font-weight: 900;
}

.story-title {
    font-family: var(--font-heading);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 5px;
}

.story-body {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.05rem;
    line-height: 1.6;
    color: #b0c4de;
    min-height: 80px;
    white-space: pre-wrap;
    /* Preserves spaces and handles wrapping */
}

.story-mechanic-box {
    background: rgba(46, 204, 113, 0.05);
    border: 1px dashed rgba(46, 204, 113, 0.3);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--success);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.story-footer {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

/* Hero Panel */
#hero-stats-board {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 0.85rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
}

.stat-btn {
    width: 32px;
    height: 32px;
    background: #2c3e50;
    border: 2px solid #d4af37;
    border-radius: 6px;
    color: #d4af37;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(212, 175, 55, 0.3);
    transition: all 0.1s ease-out;
    padding: 0;
    margin-left: 10px;
    font-family: inherit;
    user-select: none;
    flex-shrink: 0;
    transform: translateZ(0);
    /* Hardware acceleration */
}


.stat-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}


.stat-btn:hover {
    background: #d4af37;
    color: #1a1d2d;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.6);
}

.stat-btn:active {
    transform: scale(0.92);
}


/* Hero Inventory */
#hero-inventory-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.bag-tabs-container {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.bag-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 2px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.bag-tab:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.bag-tab.active {
    background: rgba(108, 92, 231, 0.15);
    border-color: var(--accent-secondary);
    box-shadow: inset 0 0 10px rgba(108, 92, 231, 0.2);
}

.bag-num {
    font-size: 0.9rem;
    font-weight: 800;
    color: #fff;
}

.bag-count {
    font-size: 0.55rem;
    font-weight: bold;
    margin-top: 2px;
}

.inventory-slots-wrapper {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.inventory-slot {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    position: relative;
    cursor: default;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.inventory-slot.occupied {
    cursor: pointer;
}

.inventory-slot.occupied:hover {
    border-color: var(--accent-secondary);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.inv-level-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: var(--accent-secondary);
    color: #000;
    font-size: 0.6rem;
    font-weight: 900;
    padding: 1px 4px;
    border-radius: 4px;
    z-index: 5;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.stat-val {
    color: var(--accent-secondary);
    font-weight: 700;
}

/* Hero Panel Overhaul (v2.11.24) */
/* Ancient Legacy Decorations */
.ancient-pillar {
    pointer-events: none;
    position: absolute;
    top: 0;
    bottom: 0;
    width: 60px;
    background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iMzAwIiB2aWV3Qm94PSIwIDAgNjAgMzAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0ic3RvbmUiIHgxPSIwIiB5MT0iMCIgeTI9IjAiPjxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiMxMjE0MWEiLz48c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iIzFjMWUyNiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzEyMTQxYSIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxwYXRoIGQ9Ik01LDAgaDUwIHYxMCBxLTI1LDEwIC01MCwwIFoiIGZpbGw9IiMzZTNhMzIiIC8+PHJlY3QgeD0iMiIgeT0iMTAiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1IiBmaWxsPSIjZDRhZjM3IiAvPjxyZWN0IHg9IjEwIiB5PSIxNSIgd2lkdGg9IjQwIiBoZWlnaHQ9IjI3MCIgZmlsbD0idXJsKCNzdG9uZSkiIC8+PHJlY3QgeD0iMTUiIHk9IjE1IiB3aWR0aD0iMyIgaGVpZ2h0PSIyNzAiIGZpbGw9IiMwMDAiIGZpbGwtb3BhY2l0eT0iMC4zIiAvPjxyZWN0IHg9IjI4IiB5PSIxNSIgd2lkdGg9IjQiIGhlaWdodD0iMjcwIiBmaWxsPSIjMDAwIiBmaWxsLW9wYWNpdHk9IjAuNCIgLz48cmVjdCB4PSI0MiIgeT0iMTUiIHdpZHRoPSIzIiBoZWlnaHQ9IjI3MCIgZmlsbD0iIzAwMCIgZmlsbC1vcGFjaXR5PSIwLjMiIC8+PHBhdGggZD0iTTEyLDUwIGwxMCwxMCBtLTUsMjAgbDgsLTUiIHN0cm9rZT0iIzAwMCIgc3Ryb2tlLW9wYWNpdHk9IjAuNSIgc3Ryb2tlLXdpZHRoPSIxIiAvPjxyZWN0IHg9IjIiIHk9IjI4NSIgd2lkdGg9IjU2IiBoZWlnaHQ9IjUiIGZpbGw9IiNjZDdmMzIiIC8+PHBhdGggZD0iTTUsMjkwIGg1MCB2MTAgcS0yNSwtNSAtNTAsMCBaIiBmaWxsPSIjM2UzYTMyIiAvPjwvc3ZnPg==");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 0 15px rgba(0, 0, 0, 0.8));
    z-index: 100;
}

.pillar-left {
    left: 0;
}

.pillar-right {
    right: 0;
    transform: scaleX(-1);
}

#hero-equipment-container {
    display: grid;
    grid-template-columns: 110px 110px 110px;
    grid-template-rows: auto auto auto auto;
    gap: 10px 12px;
    justify-content: center;
    align-content: center;
    align-items: center;
    justify-items: center;
    position: relative;
    padding: 20px 0;
    width: 100%;

    /* Background Silhouette */
    background-image: url('assets/hero_silhouette.png');
    background-position: center 10px;
    background-size: 100% auto;
    background-repeat: no-repeat;

    /* Grid Areas Definition */
    grid-template-areas:
        "artifact hat pendant"
        "weapon chest axe"
        "weapon pants axe"
        "ring1 shoes ring2";
}

/* Remove old row styles */
.equipment-row {
    display: contents;
    /* Ensures grid items are direct children */
}

/* Base Slot Style */
.equipment-slot {
    width: 96px;
    height: 96px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    justify-self: center;
    align-self: center;
}

/* Hat — slightly smaller (head piece) */
.equipment-slot[data-slot="hat"] {
    width: 84px;
    height: 84px;
}

/* Chest — largest body piece */
.equipment-slot[data-slot="chest"] {
    width: 108px;
    height: 108px;
}

/* Pants — mid-large */
.equipment-slot[data-slot="pants"] {
    width: 102px;
    height: 102px;
}

/* Shoes — slightly larger than default */
.equipment-slot[data-slot="shoes"] {
    width: 96px;
    height: 96px;
}

/* Tall Slots (Weapons) */
.equipment-slot[data-slot="weapon"],
.equipment-slot[data-slot="axe"] {
    height: 100%;
    /* Fill the 2-row span */
    width: 105px;
    /* Slightly wider */
    border-radius: 12px;
}

/* Compact Slots (Accessories) */
.equipment-slot[data-slot="ring1"],
.equipment-slot[data-slot="ring2"],
.equipment-slot[data-slot="pendant"],
.equipment-slot[data-slot="artifact"] {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    /* Make them circular or rounded */
}

/* Specific Grid Placements (Redundant with atomic classes but safer) */
/* Specific Grid Placements */
.equipment-slot[data-slot="artifact"] {
    display: flex;
    /* Ensure it's visible */
    /* Remove absolute positioning */
    position: relative;
    top: auto;
    right: auto;
}

.item-level-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    top: auto;
    /* Override previous */
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.6rem;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 4px;
    box-shadow: none;
    border: none;
    z-index: 5;
    pointer-events: auto;
    backdrop-filter: blur(2px);
}

.stat-better {
    color: var(--success) !important;
}

.stat-worse {
    color: var(--danger) !important;
}

.upgrade-btn-active {
    background: linear-gradient(135deg, var(--success), #27ae60) !important;
}

.upgrade-btn-disabled {
    background: #555 !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}

.action-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-sizing: border-box;
    position: relative;
}

.action-btn:hover {
    filter: brightness(1.2);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
    transform: none !important;
}

/* Prevent flicker loop by keeping hit area stable when button moves up */
.action-btn::after {
    content: '';
    display: none;
}

/* Zone Card Styles */
#zone-list-container {
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    transition: background-image 0.5s ease;
    border-radius: 12px;
    padding: 20px;
    min-height: 400px;
    position: relative;
}

/* Zone Card Overhaul */
.zone-card {
    display: grid;
    grid-template-columns: 110px 1fr 35px 150px;
    grid-template-rows: 120px auto;
    align-content: start;
    align-items: stretch;
    background: rgba(15, 17, 26, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 12px;
    overflow: hidden;
    min-height: 120px;
    height: auto;
    text-align: left;
    transition: min-height 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), transform 0.3s ease, border-color 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.zone-card:hover:not(.locked) {
    border-color: var(--accent-secondary);
    background: rgba(25, 27, 36, 0.95);
    transform: translateX(8px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.boss-portrait-container {
    grid-column: 1;
    grid-row: 1;
    width: 110px;
    height: 100%;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.4rem;
    position: relative;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.boss-portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
    transition: opacity 0.4s;
}

.zone-card:hover .boss-portrait-img {
    opacity: 1;
}

.zone-details {
    grid-column: 2;
    grid-row: 1;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.zone-header-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.zone-name {
    font-size: 1rem;
    font-weight: 900;
    color: #fff;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.zone-level-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 800;
    letter-spacing: 1.5px;
}

.zone-lore {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    line-height: 1.3;
    border-left: 2px solid var(--accent-primary);
    padding-left: 8px;
    margin: 2px 0 4px 0;
    max-width: 90%;
}

.zone-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 2px;
}

.zone-stat-mini {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ddd;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

.zone-actions-panel {
    grid-column: 4;
    grid-row: 1;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.combat-readiness-badge {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}

.zone-level {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Info Slider & Button */
.zone-expand-btn {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: 0.3s;
    z-index: 10;
}

.zone-expand-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-secondary);
}

.expand-icon {
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.zone-card.info-active .expand-icon {
    transform: rotate(90deg);
}

.zone-card.info-active .zone-expand-btn {
    background: var(--accent-secondary);
    color: #000;
}

.zone-card.info-active {
    min-height: 320px;
    border-color: var(--accent-secondary) !important;
}

.zone-info-slider {
    grid-row: 2;
    grid-column: 1 / -1;
    background: rgba(20, 22, 35, 0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 40px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.4s ease;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Custom Scrollbar for Info Slider */
.zone-info-slider::-webkit-scrollbar {
    width: 4px;
}

.zone-info-slider::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.zone-info-slider::-webkit-scrollbar-thumb {
    background: var(--accent-secondary);
    border-radius: 10px;
}

.zone-card.info-active .zone-info-slider {
    max-height: 320px;
    opacity: 1;
    padding: 16px 24px;
    border-bottom: 0px solid var(--accent-secondary);
}

.intelligence-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 90px;
    gap: 18px;
    margin-top: 4px;
}

.intel-column {
    display: flex;
    flex-direction: column;
}

.intel-sub-title {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 4px;
}

.intel-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #eee;
    padding: 3px 0;
}

.mastery-gift-box {
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    cursor: help;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.mastery-gift-box.unlocked {
    border: 2px solid var(--accent-secondary);
    background: rgba(var(--accent-secondary-rgb, 241, 196, 15), 0.1);
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.2);
}

.mastery-gift-box.locked {
    filter: grayscale(1);
    opacity: 0.6;
}

.mastery-gift-box:hover {
    transform: scale(1.05);
    border-color: var(--accent-secondary);
}

.info-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-secondary);
    font-weight: 800;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .intelligence-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

.info-label {
    color: var(--text-muted);
}

.info-value {
    font-weight: 700;
}

/* --- Map Regions --- */
.region-header {
    width: 100%;
    text-align: left;
    margin-top: 20px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.region-title {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #fff;
}

.region-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 2px;
}

.region-header-1 .region-title {
    color: #a8e6cf;
    text-shadow: 0 0 10px rgba(168, 230, 207, 0.3);
}

.region-header-2 .region-title {
    color: #74b9ff;
    text-shadow: 0 0 10px rgba(116, 185, 255, 0.3);
}

.region-header-3 .region-title {
    color: #e17055;
    text-shadow: 0 0 10px rgba(225, 112, 85, 0.3);
}

.region-header-4 .region-title {
    color: #a29bfe;
    text-shadow: 0 0 10px rgba(162, 155, 254, 0.3);
}

.region-header-5 .region-title {
    color: #ffeaa7;
    text-shadow: 0 0 10px rgba(255, 234, 167, 0.3);
}

/* --- Continent View --- */
.continent-card {
    width: 100%;
    min-height: 130px;
    aspect-ratio: 250 / 140;
    background: linear-gradient(rgba(22, 22, 28, 0.4), rgba(22, 22, 28, 0.4)), url('assets/old_map_texture.png');
    background-size: cover;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    /* Sharp, like a map tile */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;

    /* "Old Map" Aesthetic: Deep Vignette + Lifted Shadow */
    box-shadow:
        0 15px 35px rgba(0, 0, 0, 0.6),
        inset 0 0 50px rgba(0, 0, 0, 0.8);

    position: relative;
    overflow: hidden;
    backdrop-filter: blur(4px);
}

.continent-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7);
    border-color: #fff;
}

.continent-title {
    font-weight: 800;
    color: #fff;
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    margin-bottom: 6px;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.continent-desc {
    color: #ffca00;
    font-size: clamp(0.65rem, 1.5vw, 0.72rem);
    font-style: italic;
    z-index: 2;
}

.continent-card.locked {
    filter: grayscale(1);
    opacity: 0.7;
    cursor: not-allowed;
    border-color: #333;
}

/* Regional Borders for Continent Cards */
.continent-card.region-1 {
    border-color: #a8e6cf;
    background: linear-gradient(135deg, rgba(168, 230, 207, 0.1), rgba(0, 0, 0, 0.9)), url('assets/old_map_texture.png');
    background-size: cover;
}

.continent-card.region-2 {
    border-color: #74b9ff;
    background: linear-gradient(135deg, rgba(116, 185, 255, 0.1), rgba(0, 0, 0, 0.9)), url('assets/old_map_texture.png');
    background-size: cover;
}

.continent-card.region-3 {
    border-color: #e17055;
    background: linear-gradient(135deg, rgba(225, 112, 85, 0.1), rgba(0, 0, 0, 0.9)), url('assets/old_map_texture.png');
    background-size: cover;
}

.continent-card.region-4 {
    border-color: #a29bfe;
    background: linear-gradient(135deg, rgba(162, 155, 254, 0.1), rgba(0, 0, 0, 0.9)), url('assets/old_map_texture.png');
    background-size: cover;
}

.continent-card.region-5 {
    border-color: #ffeaa7;
    background: linear-gradient(135deg, rgba(255, 234, 167, 0.1), rgba(0, 0, 0, 0.9)), url('assets/old_map_texture.png');
    background-size: cover;
}

.continent-card.region-6 {
    border-color: #0984e3;
    background: linear-gradient(135deg, rgba(9, 132, 227, 0.15), rgba(0, 0, 0, 0.9)), url('assets/old_map_texture.png');
    background-size: cover;
}

.continent-card.region-7 {
    border-color: #6c5ce7;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(0, 0, 0, 0.9)), url('assets/old_map_texture.png');
    background-size: cover;
}

.continent-card.region-8 {
    border-color: #636e72;
    background: linear-gradient(135deg, rgba(99, 110, 114, 0.2), rgba(0, 0, 0, 0.9)), url('assets/old_map_texture.png');
    background-size: cover;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(255, 255, 255, 0.05);
}

.continent-card.region-9 {
    border-color: #fd79a8;
    background: linear-gradient(135deg, rgba(253, 121, 168, 0.15), rgba(0, 0, 0, 0.9)), url('assets/old_map_texture.png');
    background-size: cover;
}

.continent-card.region-10 {
    border-color: #d63031;
    background: linear-gradient(135deg, rgba(214, 48, 49, 0.2), rgba(0, 0, 0, 0.9)), url('assets/old_map_texture.png');
    background-size: cover;
}

/* Chapter 2 Regions (v2.75.0) */
.continent-card.region-11 {
    background: linear-gradient(rgba(206, 214, 224, 0.2), rgba(0, 0, 0, 0.8)), url('assets/old_map_texture.png');
    border-color: #ced6e0;
    background-size: cover;
}

.continent-card.region-12 {
    background: linear-gradient(rgba(241, 196, 15, 0.2), rgba(0, 0, 0, 0.8)), url('assets/old_map_texture.png');
    border-color: #f1c40f;
    background-size: cover;
}

.continent-card.region-13 {
    background: linear-gradient(rgba(223, 228, 234, 0.2), rgba(0, 0, 0, 0.8)), url('assets/old_map_texture.png');
    border-color: #dfe4ea;
    background-size: cover;
}

.continent-card.region-14 {
    background: linear-gradient(rgba(162, 155, 254, 0.2), rgba(0, 0, 0, 0.8)), url('assets/old_map_texture.png');
    border-color: #a29bfe;
    background-size: cover;
}

.continent-card.region-15 {
    background: linear-gradient(rgba(116, 185, 255, 0.2), rgba(0, 0, 0, 0.8)), url('assets/old_map_texture.png');
    border-color: #74b9ff;
    background-size: cover;
}

.continent-card.region-16 {
    background: linear-gradient(rgba(162, 155, 254, 0.2), rgba(0, 0, 0, 0.8)), url('assets/old_map_texture.png');
    border-color: #a29bfe;
    background-size: cover;
}

.continent-card.region-17 {
    background: linear-gradient(rgba(250, 177, 160, 0.2), rgba(0, 0, 0, 0.8)), url('assets/old_map_texture.png');
    border-color: #fab1a0;
    background-size: cover;
}

.continent-card.region-18 {
    background: linear-gradient(rgba(0, 210, 211, 0.2), rgba(0, 0, 0, 0.8)), url('assets/old_map_texture.png');
    border-color: #00d2d3;
    background-size: cover;
}

.continent-card.region-19 {
    background: linear-gradient(rgba(45, 52, 54, 0.2), rgba(0, 0, 0, 0.8)), url('assets/old_map_texture.png');
    border-color: #2d3436;
    background-size: cover;
}

.continent-card.region-20 {
    background: linear-gradient(rgba(255, 159, 67, 0.2), rgba(0, 0, 0, 0.8)), url('assets/old_map_texture.png');
    border-color: #ff9f43;
    background-size: cover;
}

/* Chapter Switcher UI */
.chapter-switcher {
    display: flex;
    gap: 10px;
    margin: 8px 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px;
    border-radius: 40px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.chapter-btn {
    padding: 7px 16px;
    border-radius: 35px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 900;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.chapter-btn:hover:not(.locked) {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.chapter-btn.active {
    background: linear-gradient(135deg, var(--accent-primary), #0984e3);
    color: #fff;
    box-shadow: 0 0 20px rgba(0, 168, 255, 0.4);
}

.chapter-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

.region-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 25px;
    width: 100%;
    padding: 10px;
    justify-items: center;
}

/* Legacy border rules removed */

/* Stellar Core (Cosmic/Gold) */

#continent-view {
    min-height: 30vh;
    max-height: 80vh;
    overflow-x: hidden;
}

.region-1.locked {
    border-color: #555;
}

.zone-name {
    font-weight: 700;
    color: var(--text-main);
    font-size: 1rem;
}

.boss-icon-display {
    font-size: 3rem;
    margin: 10px 0;
    width: 100%;
    text-align: center;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
    transition: transform 0.3s ease;
}

.zone-card:hover .boss-icon-display {
    transform: scale(1.2);
}

.boss-info {
    font-size: 0.8rem;
    color: var(--danger);
    font-weight: 600;
}

.travel-btn {
    background: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-top: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.zone-card:not(.locked):hover .travel-btn {
    background: var(--accent-primary);
    color: white;
}

/* Custom Tooltip */
#game-tooltip {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    padding: 12px;
    background: rgba(15, 17, 26, 0.98);
    border: 1px solid var(--accent-secondary);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #fff;
    max-width: 340px;
    max-height: 95vh;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s;
    backdrop-filter: blur(10px);
    scrollbar-width: thin;
    scrollbar-color: var(--accent-secondary) transparent;
}

#game-tooltip.locked {
    max-height: 95vh;
    overflow-y: auto;
    pointer-events: auto;
    border-color: #f1c40f;
    /* Highlight locked state with gold */
    box-shadow: 0 0 40px rgba(241, 196, 15, 0.2);
}

#game-tooltip::-webkit-scrollbar {
    width: 6px;
}

#game-tooltip::-webkit-scrollbar-thumb {
    background: var(--accent-secondary);
    border-radius: 10px;
}

#game-tooltip.active {
    opacity: 1;
    visibility: visible;
}

.tooltip-close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    z-index: 100;
    transition: all 0.2s;
}

.tooltip-close-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    transform: scale(1.1);
}

.tooltip-title {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 5px;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}

.tooltip-rarity {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.stat-better {
    color: var(--success);
}

.stat-worse {
    color: var(--danger);
}

.tooltip-comparison {
    border-top: 1px dashed #555;
    margin-top: 10px;
    padding-top: 8px;
    font-size: 0.85rem;
    color: #aaa;
}

/* --- Hero Travel Corridor --- */
#travel-corridor {
    position: relative;
    width: 100%;
    height: 120px;
    background: linear-gradient(180deg, rgba(26, 29, 45, 0.98) 0%, rgba(15, 17, 26, 0.98) 100%);
    border-top: 3px solid var(--accent-secondary);
    border-bottom: 3px solid var(--accent-secondary);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5), inset 0 0 100px rgba(166, 26, 26, 0.1);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    /* Ensure it's on top of everything */
    margin-top: auto;
    overflow: visible;
    /* Allow timer to pop out */
}


#travel-timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    padding: 7px 20px;
    border-radius: 15px;
    border: 1px solid rgba(166, 26, 26, 0.3);
    backdrop-filter: blur(15px);
    z-index: 2010;
    /* Above corridor */
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.8);
    position: absolute;
    top: -30px;
}

#travel-timer-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent-secondary);
    letter-spacing: 2px;
    margin-bottom: 2px;
}

#travel-timer-value {
    font-size: 1.4rem;
    font-weight: 950;
    font-family: 'Outfit', sans-serif;
    color: #fff;
    text-shadow: 0 0 15px var(--accent-secondary);
}

#hero-traveler {
    position: absolute;
    left: 0;
    top: 15px;
    /* Centered in 120px height (120-90=30, /2=15) */
    width: 90px;
    height: 90px;
    font-size: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none;
    filter: drop-shadow(0 0 30px var(--accent-secondary));
    transform-origin: 50% 100%;

    z-index: 55;
    background-image: url('hero_run.png');
    background-size: auto 100%;
    background-repeat: no-repeat;
    background-color: transparent;
    background-position: 0 0;
    animation: hero-stride 0.32s cubic-bezier(.4, 0, .6, 1) infinite;
}

#hero-traveler::before {
    content: '';
    position: absolute;
    left: -6px;
    bottom: 2px;
    width: 30px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(220, 200, 170, 0.55) 0%, rgba(180, 160, 130, 0.25) 50%, transparent 75%);
    pointer-events: none;
    animation: dust-puff 0.32s linear infinite;
    z-index: -1;
}

#hero-traveler::after {
    content: '';
    position: absolute;
    right: 70%;
    top: 30%;
    width: 70px;
    height: 60%;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.35) 50%, transparent 100%) 0 20% / 100% 2px no-repeat,
        linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.25) 50%, transparent 100%) 0 55% / 100% 2px no-repeat,
        linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.30) 50%, transparent 100%) 0 85% / 100% 2px no-repeat;
    animation: speed-lines 0.32s linear infinite;
    z-index: -1;
}

@keyframes hero-stride {

    0%,
    100% {
        transform: translateY(0) rotate(-4deg) scaleY(0.94);
    }

    50% {
        transform: translateY(-14px) rotate(-8deg) scaleY(1);
    }
}

@keyframes dust-puff {
    0% {
        opacity: 0.6;
        transform: translateX(0) scale(0.4);
    }

    100% {
        opacity: 0;
        transform: translateX(-30px) scale(1.4);
    }
}

@keyframes speed-lines {
    0% {
        opacity: 0;
        transform: translateX(20px);
    }

    30% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateX(-40px);
    }
}

@media (prefers-reduced-motion: reduce) {
    #hero-traveler {
        animation: hero-bounce-calm 0.6s ease-in-out infinite;
    }

    #hero-traveler::before,
    #hero-traveler::after {
        display: none;
    }

    @keyframes hero-bounce-calm {

        0%,
        100% {
            transform: translateY(0);
        }

        50% {
            transform: translateY(-10px);
        }
    }
}

#boss-target {
    position: absolute;
    right: 30px;
    top: 15px;
    /* Centered in 120px height */
    width: 90px;
    height: 90px;
    font-size: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 30px var(--danger));
    z-index: 55;
}

/* --- Settings Panel --- */
.settings-group {
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 10px;
}

.settings-group h4 {
    margin-top: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#save-data-field {
    outline: none;
    transition: border-color 0.2s;
}

#save-data-field:focus {
    border-color: var(--accent-primary);
}

#floating-text-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
}

.floating-text {
    position: absolute;
    color: #fff;
    font-weight: 950;
    font-size: 1.2rem;
    pointer-events: none;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8), 2px 2px 2px #000;
    animation: float-up 1s ease-out forwards;
    white-space: nowrap;
    z-index: 10000;
}

@keyframes float-up {
    0% {
        transform: translate(-50%, 0) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -120px) scale(0.8);
        opacity: 0;
    }
}

#rock.hit {
    animation: rock-hit 0.1s ease-out;
}

@keyframes rock-hit {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.92);
    }

    100% {
        transform: scale(1);
    }
}

#global-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(20, 20, 25, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.resource-group {
    display: contents; /* Makes groups invisible to flex — items become direct children of footer */
}

.resource-item {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s ease, background 0.2s ease;
}

.resource-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.resource-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

.resource-details {
    display: flex;
    flex-direction: column;
}

.resource-value {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    line-height: 1;
}

.resource-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.05rem;
    margin-top: 2px;
}

#astral-flux-item {
    border-color: rgba(0, 243, 255, 0.2);
}

#void-shards-item {
    border-color: rgba(255, 0, 255, 0.2);
}

#gem-item {
    border-color: rgba(0, 229, 255, 0.2);
}

#ore-display {
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

#ops-group {
    border-color: rgba(255, 215, 0, 0.2);
}

#ops-display {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

#know-group {
    border-color: rgba(162, 115, 255, 0.2);
}

#knowledge-display {
    color: #a273ff;
    text-shadow: 0 0 10px rgba(162, 115, 255, 0.3);
}

#kps-group {
    border-color: rgba(0, 255, 127, 0.2);
}

#kps-display {
    color: #00ff7f;
    text-shadow: 0 0 10px rgba(0, 255, 127, 0.3);
}

/* --- Hero Sub-Tabs UI (Shared/Desktop) --- */
.sub-nav-desktop {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sub-nav-desktop .sub-nav-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 0;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.sub-nav-desktop .sub-nav-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.sub-nav-desktop .sub-nav-btn.active {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.hero-view {
    display: none;
    animation: slideUp 0.3s ease-out;
}

.hero-view.active {
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Avatar Selection UI --- */
#avatar-selection-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.avatar-list-header {
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 15px 0 5px;
}

.avatar-choice {
    flex: 0 0 calc(33.33% - 12px);
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    font-size: 2.5rem;
}

.avatar-choice.locked {
    cursor: help;
    background: rgba(0, 0, 0, 0.4);
}

.avatar-choice.active {
    border-color: var(--accent-secondary);
    background: rgba(0, 206, 201, 0.1);
}

.avatar-choice img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-lock-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    text-shadow: 0 0 5px #000;
    pointer-events: none;
}

.avatar-choice .avatar-save-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    border: none;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 1px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 2;
}

.avatar-choice.active .avatar-save-overlay,
.avatar-choice:hover .avatar-save-overlay {
    opacity: 1;
}

.avatar-choice .avatar-save-overlay:hover {
    background: var(--success);
}

/* --- Battle Avatars (Combat View) --- */
.battle-avatar {
    width: 240px;
    height: 240px;
    background: rgba(0, 0, 0, 0.4);
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    margin: 0 auto;
    font-size: 8rem;
    /* Large icons for desktop */
}

.battle-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.battle-avatar.boss {
    border-color: var(--danger);
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.3);
}

.battle-avatar.hero {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.3);
}

/* Responsive adjustment for combat side-by-side */
@media (max-width: 1000px) {
    .battle-avatar {
        width: 110px;
        height: 110px;
        font-size: 4rem;
        /* Adjusted for mobile */
    }
}

/* Force dimensions on specific IDs to prevent any override issues */
#combat-hero-avatar,
#combat-boss-avatar {
    width: 240px;
    height: 240px;
    max-width: 240px;
    max-height: 240px;
}

#combat-hero-avatar img,
#combat-boss-avatar img {
    width: 240px;
    height: 240px;
    object-fit: cover;
}

/* --- Hero Tab Main Avatar --- */
#hero-avatar-display {
    width: 90%;
    height: 90%;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    margin: 0 auto;
    font-size: 8rem;
    /* Large emoji support */
    text-align: center;
}

#hero-avatar-display span {
    font-size: 8rem;
    line-height: 1;
    display: block;
}

#hero-avatar-display img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
    display: block;
}

/* World Map Launcher */
#world-map-launcher {
    position: absolute;
    top: 20px;
    right: 20px;
    /* Top right corner */
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    z-index: 20;
    /* Above upgrades bar if needed */
    transition: transform 0.2s;
}

#world-map-launcher:hover {
    transform: scale(1.1);
}

#world-map-launcher img {
    width: 100px;
    height: 100px;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: transparent;
}

.map-label {
    margin-top: 5px;
    font-size: 0.8rem;
    font-weight: 800;
    color: #deb887;
    /* Burlywood/Parchment color */
    text-shadow: 2px 2px 0 #000;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-family: 'Outfit', sans-serif;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Ancient Legacy Decorations */
.ancient-pillar {
    pointer-events: none;
    position: absolute;
    top: 0;
    bottom: 0;
    width: 60px;
    background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iMzAwIiB2aWV3Qm94PSIwIDAgNjAgMzAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0ic3RvbmUiIHgxPSIwIiB5MT0iMCIgeDI9IjEiIHkyPSIwIj48c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjMzUzYjQ4Ii8+PHN0b3Agb2Zmc2V0PSI1MCUiIHN0b3AtY29sb3I9IiM3MTgwOTMiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMzNTNiNDgiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48cGF0aCBkPSJNNSwwIGg1MCB2MTAgcS0yNSwxMCAtNTAsMCBaIiBmaWxsPSIjMmYzNjQwIiAvPjxyZWN0IHg9IjIiIHk9IjEwIiB3aWR0aD0iNTYiIGhlaWdodD0iNSIgZmlsbD0iIzdmOGM4ZCIgLz48cmVjdCB4PSIxMCIgeT0iMTUiIHdpZHRoPSI0MCIgaGVpZ2h0PSIyNzAiIGZpbGw9InVybCgjc3RvbmUpIiAvPjxyZWN0IHg9IjE1IiB5PSIxNSIgd2lkdGg9IjMiIGhlaWdodD0iMjcwIiBmaWxsPSIjMDAwIiBmaWxsLW9wYWNpdHk9IjAuMiIgLz48cmVjdCB4PSIyOCIgeT0iMTUiIHdpZHRoPSI0IiBoZWlnaHQ9IjI3MCIgZmlsbD0iIzAwMCIgZmlsbC1vcGFjaXR5PSIwLjMiIC8+PHJlY3QgeD0iNDIiIHk9IjE1IiB3aWR0aD0iMyIgaGVpZ2h0PSIyNzAiIGZpbGw9IiMwMDAiIGZpbGwtb3BhY2l0eT0iMC4yIiAvPjxwYXRoIGQ9Ik0xMiw1MCBsMTAsMTAgbS01LDIwIGw4LC01IiBzdHJva2U9IiMwMDAiIHN0cm9rZS1vcGFjaXR5PSIwLjQiIHN0cm9rZS13aWR0aD0iMSIgLz48cmVjdCB4PSIyIiB5PSIyODUiIHdpZHRoPSI1NiIgaGVpZ2h0PSI1IiBmaWxsPSIjN2Y4YzhkIiAvPjxwYXRoIGQ9Ik01LDI5MCBoNTAgdjEwIHEtMjUsLTUgLTUwLDAgWiIgZmlsbD0iIzJmMzY0MCIgLz48L3N2Zz4=");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 0 15px rgba(0, 0, 0, 0.8));
    z-index: -1;
}

.pillar-left {
    left: 0;
}

.pillar-right {
    right: 0;
    transform: scaleX(-1);
}

@media (min-width: 1024px) {
    .ancient-pillar {
        width: 75px;
    }
}

@keyframes singularityPulse {
    0% {
        box-shadow: 0 0 10px rgba(255, 170, 0, 0.4), 0 0 0px rgba(255, 255, 255, 0), inset 0 0 5px rgba(255, 170, 0, 0.2);
        border-color: rgba(255, 170, 0, 0.5);
    }

    50% {
        box-shadow: 0 0 30px rgba(255, 200, 0, 0.9), 0 0 50px rgba(255, 255, 255, 0.4), inset 0 0 15px rgba(255, 170, 0, 0.5);
        border-color: rgba(255, 255, 255, 1);
    }

    100% {
        box-shadow: 0 0 10px rgba(255, 170, 0, 0.4), 0 0 0px rgba(255, 255, 255, 0), inset 0 0 5px rgba(255, 170, 0, 0.2);
        border-color: rgba(255, 170, 0, 0.5);
    }
}

.singularity-equipped-glow {
    animation: singularityPulse 4s infinite ease-in-out !important;
    border-width: 2px !important;
    z-index: 10 !important;
}

@keyframes transcendedPulse {
    0%, 100% {
        box-shadow: 0 0 20px var(--tc-shadow-dim), 0 0 4px var(--tc-shadow-dim), inset 0 0 10px var(--tc-inner-dim);
        border-color: var(--tc-border-dim);
    }

    50% {
        box-shadow: 0 0 40px var(--tc-shadow-bright), 0 0 60px var(--tc-shadow-dim), inset 0 0 20px var(--tc-inner-bright);
        border-color: var(--tc-border-bright);
    }
}

.transcended-equipped-glow {
    animation: transcendedPulse 4s infinite ease-in-out !important;
    border-width: 2px !important;
    z-index: 10 !important;
}

/* Settings View Tabs */
.sub-nav-desktop {
    display: flex;
    gap: 6px;
    width: 100%;
}

.settings-view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.settings-view.active {
    display: block;
}

/* Hero Panel Views */
.hero-view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.hero-view.active {
    display: block;
}

/* Tavern Panel Views */
.tavern-view {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tavern-view.active {
    display: block;
}

#settings-panel {
    padding: 5px !important;
}

#settings-panel h3 {
    font-size: 1rem !important;
    letter-spacing: 1px;
    margin-bottom: 15px !important;
}

#settings-panel h4 {
    font-size: 0.75rem !important;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#settings-panel p {
    font-size: 0.7rem !important;
}

#settings-panel .action-btn {
    padding: 8px 15px;
    font-size: 0.75rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-sub-nav-btn {
    /* Use existing nav-btn styles if applicable, otherwise custom */
    flex: 1;
    padding: 6px 2px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-family: sans-serif;
    font-size: 0.55rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
    letter-spacing: 0.2px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
}

.settings-sub-nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.settings-sub-nav-btn.active {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

/* --- Tutorial System --- */
#tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    /* Darker for more contrast */
    z-index: 10000;
    display: none;
    pointer-events: all;
    backdrop-filter: blur(0px);
}

.tutorial-spotlight {
    position: relative !important;
    z-index: 10002 !important;
    /* Box shadow simulates the "hole" in the overlay, plus a glow */
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.85), 0 0 30px var(--accent-primary) !important;
    background: #1e2228 !important;
    /* Solid background to ensure opacity */
    border: 2px solid var(--accent-primary) !important;
    /* The requested "rectangle" */
    border-radius: 8px;
    pointer-events: auto !important;
    transition: all 0.3s ease;
    transform: scale(1.05);
    /* Slight pop */
}

#tutorial-box {
    position: fixed;
    width: 300px;
    background: linear-gradient(135deg, #2b323a 0%, #1e2228 100%);
    border: 1px solid var(--accent-primary);
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    z-index: 10005;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

#tutorial-box.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

#tutorial-box h2 {
    color: var(--accent-primary);
    font-size: 1.2rem;
    margin-bottom: 10px;
}

#tutorial-box p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 15px;
    color: var(--text-muted);
}

#tutorial-next-btn {
    width: 100%;
    padding: 10px;
    background: var(--accent-primary);
    border: none;
    border-radius: 6px;
    color: #000;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    transition: filter 0.2s;
}

#tutorial-next-btn:hover {
    filter: brightness(1.2);
}

@media (max-width: 768px) {
    #tutorial-box {
        width: 90%;
        left: 50% !important;
        transform: translate(-50%, 0) !important;
    }

    #tutorial-box.centered {
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
}

/* --- Desktop Combat View Layout --- */
#main-stage #combat-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 200;

    /* Flex Layout Items */
    flex-direction: column;
    align-items: center;
    justify-content: center;

    /* Ensure it stays strictly inside */
    overflow: hidden;
}

#main-stage #combat-view.active {
    display: flex;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.toggle-slider {
    background-color: rgba(212, 175, 55, 0.2);
    border-color: var(--accent-primary);
}

input:checked+.toggle-slider:before {
    background-color: var(--accent-primary);
    transform: translateX(20px);
}

/* Pets Tab UI Refinements */
.pet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    will-change: transform;
    transform: translateZ(0);
    /* Hardware acceleration */
}

.pet-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    position: relative;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.pet-card.active {
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.3);
    box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.05);
}

.pet-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.03);
}

.pet-card.active:hover {
    border-color: var(--accent-primary);
}

.pet-avatar-frame {
    background: rgba(255, 255, 255, 0.03);
    padding: 5px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.pet-card:hover .pet-avatar-frame {
    transform: scale(1.05);
}

.pet-xp-bar-outer {
    height: 4px;
    background: #1a1a1a;
    border-radius: 2px;
    overflow: hidden;
}

.pet-xp-bar-inner {
    height: 100%;
    background: var(--accent-primary);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hatchery specific */
.incubator-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.2s ease;
}

.incubator-item:hover {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Mercenary Avatars Desktop */
.merc-avatar-rec {
    width: 112px;
    height: 130px;
    background: none;
    border: none;
}

.merc-avatar-roster {
    width: 138px;
    height: 160px;
    background: none;
    border: none;
}

/* World Map Responsiveness */
@media (min-width: 1024px) {
    .region-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 350px));
    }
    #continent-view {
        max-height: 90vh;
    }
    .map-header {
        padding: 15px 0 !important;
    }
    body {
        width: 100vw;
        height: 100vh;
    }
    #app {
        width: 100vw;
        height: 100vh;
    }
}

@media (max-width: 1000px) {
    .region-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 250px));
    }
}

.ascension-portal {
    width: auto !important;
    max-width: 500px;
    margin: 25px auto 0 auto;
    grid-column: span 1; /* Ensure it doesn't span */
    aspect-ratio: 500 / 180;
}

/* ─── Resource Bar Selector ─────────────────────────────────── */
.resource-bar-gear {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.2s;
    padding: 4px 8px;
    flex: 0 0 auto;
    color: #aaa;
}
.resource-bar-gear:hover {
    opacity: 1;
}

#resource-selector-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

#resource-selector-modal {
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 20px 24px;
    min-width: 280px;
    max-width: 360px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.resource-selector-hint {
    font-size: 0.8rem;
    color: #888;
    margin: 0 0 12px;
}

.resource-selector-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 6px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    transition: background 0.15s;
}
.resource-selector-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.resource-selector-row input[type="checkbox"] {
    accent-color: var(--accent-primary, #6c5ce7);
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.resource-selector-row input[type="checkbox"]:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Mercenary mission duration slider */
input[type="range"].mission-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-bronze, #b08d57), #222);
    outline: none;
    cursor: pointer;
    margin: 2px 0;
}
input[type="range"].mission-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary, #d4af37);
    border: 2px solid var(--bg-panel, #1a1c26);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
    cursor: pointer;
}
input[type="range"].mission-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary, #d4af37);
    border: 2px solid var(--bg-panel, #1a1c26);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
    cursor: pointer;
}
input[type="range"].mission-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-bronze, #b08d57), #222);
}

.resource-selector-counter {
    text-align: center;
    margin: 12px 0 8px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.resource-selector-confirm {
    width: 100%;
    padding: 10px;
    background: var(--accent-primary, #6c5ce7);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    transition: filter 0.2s;
}
.resource-selector-confirm:hover {
    filter: brightness(1.15);
}