:root {
    --osrs-bg: #3e3529;
    --osrs-panel: #5b4a35;
    --osrs-border: #2b2318;
    --osrs-text: #ffff00;
    --osrs-text-shadow: 2px 2px 0px #000000;
    --osrs-orange: #ff981f;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    font-family: 'Press Start 2P', cursive;
    background: url('./assets/background.png') no-repeat center center fixed;
    background-size: cover;
    color: var(--osrs-text);
    height: 100vh;
    overflow: hidden;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    width: 900px;
    height: 800px;
    background-color: rgba(62, 53, 41, 0.95);
    border: 4px solid #5d5244;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    padding: 10px;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--osrs-border);
    padding-bottom: 10px;
}

h1 {
    font-size: 24px;
    text-shadow: var(--osrs-text-shadow);
    margin-bottom: 15px;
    color: var(--osrs-orange);
}

/* Kingdom Banner */
.merchant-timer-bar {
    position: absolute;
    bottom: 5px;
    right: 5px;
    left: auto;
    transform: none;
    width: auto;
    min-width: 150px;
    padding: 6px 12px;
    text-align: center;
    font-size: 9px;
    border-radius: 4px;
    z-index: 100;
    white-space: nowrap;
}

.merchant-timer-bar.active {
    color: #4caf50;
    border-color: #2e7d32;
}

.merchant-timer-bar.away {
    color: #ff4444;
    border-color: #b71c1c;
}

.kingdom-banner {
    position: absolute;
    top: -5px;
    right: 30px;
    background: linear-gradient(135deg, #e6c200 0%, #b8860b 100%);
    color: #2b2318;
    padding: 12px 30px 15px 30px;
    font-size: 10px;
    font-weight: bold;
    border: 2px solid #3e2a1c;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.6);
    z-index: 100;
    text-transform: uppercase;
    letter-spacing: 2px;
    min-width: 180px;
    text-align: center;
    image-rendering: pixelated;
}

.kingdom-banner::before, .kingdom-banner::after {
    content: '';
    position: absolute;
    bottom: -15px;
    width: 0;
    height: 0;
    border-top: 15px solid #b8860b;
}

.kingdom-banner::before {
    left: 0;
    border-right: 90px solid transparent;
}

.kingdom-banner::after {
    right: 0;
    border-left: 90px solid transparent;
}

/* Stats Bar - Improved for Stability */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    background: rgba(0, 0, 0, 0.4);
    padding: 10px;
    border: 2px solid #5d4037;
    border-radius: 4px;
    margin-bottom: 15px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 1px;
    background: #2b2318;
    border: 1px solid #6b4423;
    border-radius: 4px;
    min-width: 100px;
}

.stat-box .label {
    font-size: 8px;
    color: #ffd700;
    margin-bottom: 2px;
    font-weight: bold;
}

.stat-box .value {
    font-size: 11px;
    color: #fff;
    font-family: 'Courier New', Courier, monospace;
}

.res-icon {
    width: 20px;
    height: 20px;
    margin-bottom: 4px;
    image-rendering: pixelated;
    object-fit: contain;
}

.sell-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 15px;
}

.sell-item {
    background: linear-gradient(135deg, #3d3023 0%, #2b2318 100%);
    border: 3px double #5d4a35;
    border-radius: 8px;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.sell-item:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: #ffd700;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
    background: linear-gradient(135deg, #4a3a2f 0%, #3a2e24 100%);
}

.sell-item.preferred {
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.sell-item-header {
    margin-bottom: 15px;
}

.sell-icon-container {
    position: relative;
    width: 64px;
    height: 64px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #5d4a35;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.sell-icon {
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
    object-fit: contain;
}

.owned-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #000;
    color: #00ff00;
    padding: 2px 6px;
    font-size: 10px;
    border: 1px solid #444;
    border-radius: 4px;
    font-weight: bold;
}

.hot-badge {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff4400;
    color: white;
    font-size: 8px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(255, 68, 0, 0.4);
    animation: pulse-hot 1.5s infinite;
}

@keyframes pulse-hot {
    0% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.1); }
    100% { transform: translateX(-50%) scale(1); }
}

.sell-item-body {
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
}

.sell-name {
    font-size: 12px;
    color: #fff;
    margin-bottom: 8px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.sell-price-tag {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #444;
    color: #ffd700;
    font-size: 11px;
}

.price-coin-icon {
    width: 14px;
    height: 14px;
    margin-right: 6px;
}

.sell-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    width: 100%;
}

.sell-btn {
    padding: 8px 4px;
    font-family: inherit;
    font-size: 9px;
    border-radius: 4px;
    border: 1px solid #5d4a35;
    cursor: pointer;
    transition: all 0.1s;
    background: #4e342e;
    color: #fff;
}

.sell-btn:hover:not(:disabled) {
    background: #6d4c41;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.sell-btn:disabled {
    opacity: 0.3;
    filter: grayscale(1);
    cursor: not-allowed;
}

.sell-btn.all {
    background: #2e7d32;
    border-color: #1b5e20;
}

.sell-btn.all:hover:not(:disabled) {
    background: #388e3c;
}

.animated-glow {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    animation: border-glow 2s infinite;
}

@keyframes border-glow {
    0% { border-color: #5d4a35; }
    50% { border-color: #ffd700; }
    100% { border-color: #5d4a35; }
}

/* Main Navigation */
.main-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.nav-btn {
    padding: 10px 15px;
    background: linear-gradient(to bottom, #4e342e, #3e2723);
    border: 2px solid #5d4037;
    color: #ffd700;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    font-size: 10px;
}

.nav-btn:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
}

.nav-btn.active {
    background: linear-gradient(to bottom, #ffd700, #b8860b);
    color: #000;
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

/* Layouts */
#game-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.game-view-section {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Each section handles its own scrolling */
}

.click-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    align-items: start;
    height: 100%; /* Fill available space */
}

.coin-column {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 2px inset var(--osrs-border);
    border-radius: 4px;
    height: 100%; /* Fill click layout */
    width: 350px;
}

.shop-column {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.merchant-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.merchant-header {
    background: #4a3b2a;
    border: 2px solid #2b2318;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.preferred-notice {
    color: #ffd700;
    font-size: 10px;
    margin-top: 10px;
    background: rgba(0,0,0,0.4);
    padding: 8px;
    border-left: 4px solid #ffd700;
}

.sell-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 15px;
    overflow-y: auto;
    padding-right: 10px;
}

.sell-item {
    background: #3e3529;
    border: 2px solid #2b2318;
    padding: 12px;
    border-radius: 4px;
    transition: transform 0.2s;
}

.sell-item.preferred {
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.sell-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sell-name { color: #fff; font-size: 10px; }
.sell-owned { color: #ffd700; font-size: 10px; }
.sell-price { color: #4af; font-size: 9px; margin-bottom: 12px; }

.sell-actions {
    display: flex;
    gap: 5px;
}

.sell-btn {
    flex: 1;
    padding: 6px;
    font-size: 8px;
    font-family: inherit;
    border: 2px solid #000;
    cursor: pointer;
    background: #5d4037;
    color: #fff;
}

.sell-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.sell-btn:hover:not(:disabled) { filter: brightness(1.2); }

.detailed-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    background: #2b2318;
    padding: 20px;
    border: 2px solid #6b4423;
    border-radius: 6px;
    flex: 1;
    overflow-y: auto;
}

.stats-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.stat-entry {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid #444;
}

.stat-entry .label { color: #aaa; font-size: 11px; }
.stat-entry .value { color: #ffd700; font-weight: bold; font-size: 12px; }

/* Merchant State Styles */
.merchant-away-message {
    padding: 60px 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.4);
    border: 2px dashed #7a6a3e;
    border-radius: 8px;
    margin: 40px 0;
}

.merchant-away-message h3 {
    margin-bottom: 15px;
    color: #ffd700;
    text-shadow: 2px 2px 0 #000;
}

.merchant-away-message p {
    color: #aaa;
    font-size: 10px;
}

.merchant-timer {
    margin-top: 25px;
    font-size: 9px;
    color: #4af;
    background: rgba(0,0,0,0.4);
    display: inline-block;
    padding: 8px 15px;
    border-radius: 4px;
    border-left: 4px solid #4af;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
}

/* Account/Progression View */
.account-container {
    background: rgba(0, 0, 0, 0.4);
    border: 3px solid #b3a164;
    padding: 20px;
    border-radius: 8px;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.account-header {
    margin-bottom: 25px;
    text-align: center;
    border-bottom: 1px solid rgba(179, 161, 100, 0.3);
    padding-bottom: 15px;
}

.account-sub {
    font-size: 8px;
    color: #ffd700;
    margin-top: 5px;
    opacity: 0.8;
}

.account-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.account-left, .account-right {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.equipment-section h3, .effects-section h3, .loot-section h3 {
    margin-bottom: 15px;
    font-size: 14px;
    color: #ffd700;
    text-shadow: 1px 1px 0 #000;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Effects List */
.effects-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0,0,0,0.3);
    padding: 12px;
    border: 1px solid #444;
    border-radius: 4px;
}

.effect-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    border-left: 3px solid #ffd700;
    font-size: 10px;
}

.effect-name {
    color: #ddd;
}

.effect-value {
    color: #4caf50;
    font-weight: bold;
}

.equipment-section h3, .loot-section h3 {
    font-size: 10px;
    color: #ffa500;
    margin-bottom: 15px;
    text-transform: uppercase;
    border-bottom: 2px solid #2b2318;
    padding-bottom: 8px;
}

.equipped-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-areas:
        ". helm ."
        "weapon body shield"
        ". legs ."
        ". boots .";
    gap: 10px;
    max-width: 350px; /* Slightly tighter for vertical layout */
    margin: 0 auto;
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #7a6a3e;
}

.slot-helm { grid-area: helm; }
.slot-body { grid-area: body; }
.slot-legs { grid-area: legs; }
.slot-boots { grid-area: boots; }
.slot-shield { grid-area: shield; }
.slot-weapon { grid-area: weapon; }

.equipped-slot {
    aspect-ratio: 1;
    background: #4a3b2a;
    border: 3px double #2b2318;
    border-radius: 4px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    cursor: pointer;
    min-height: 80px;
}

.equipped-slot.empty {
    opacity: 0.4;
    border-style: dashed;
}

.equipped-slot img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    margin-bottom: 5px;
    object-fit: contain;
}

.equipped-slot:hover {
    border-color: #ffd700;
    background: #5e4e3a;
}

.equipped-label {
    position: absolute;
    bottom: 5px;
    font-size: 7px;
    color: #aaa;
    text-transform: uppercase;
    font-weight: bold;
    text-align: center;
    line-height: 11px;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

.inventory-slot {
    background: linear-gradient(135deg, #4e402a 0%, #3a301f 100%);
    border: 3px double #2b2318;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 140px;
}

.inventory-slot:hover {
    border-color: #ffd700;
    transform: translateY(-2px);
    background: linear-gradient(135deg, #5e4e3a 0%, #4a3a2f 100%);
}

.inventory-slot img {
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
    margin-bottom: 8px;
    object-fit: contain;
}

.inventory-slot .item-name {
    font-size: 10px;
    color: #fff;
    margin-bottom: 4px;
}

.inventory-slot .item-count {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #000;
    color: #ffd700;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 4px;
    border: 1px solid #7a6a3e;
    font-weight: bold;
    z-index: 10;
    min-width: 18px;
    height: auto;
    line-height: normal;
    text-align: center;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    white-space: nowrap;
    width: auto;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.inventory-slot .item-tier {
    font-size: 8px;
    text-transform: uppercase;
    color: #ffd700;
}

.inventory-slot .open-hint {
    font-size: 8px;
    color: #4caf50;
    margin-top: 10px;
    font-style: italic;
    opacity: 0.9;
    letter-spacing: 0.5px;
}


.inventory-slot.easy { border-color: #cd7f32; border-style: double; }
.inventory-slot.medium { border-color: #6b4422; border-style: double; }
.inventory-slot.hard { border-color: #333; border-style: double; }
.inventory-slot.elite { border-color: #32cd32; border-style: double; }
.inventory-slot.master { border-color: #ffd700; border-style: double; animation: casket-glow 2s infinite alternate; }

/* Item Specific Styling */
.inventory-slot.item {
    border-style: solid;
    min-height: 160px;
    justify-content: flex-start;
}

.inventory-slot.item .bonus-text {
    font-size: 7px;
    color: #4caf50;
    margin-top: 8px;
    line-height: 1.4;
    font-style: italic;
    background: rgba(0,0,0,0.3);
    padding: 5px;
    border-radius: 4px;
    width: 100%;
}

.inventory-slot.item.equipped {
    border: 3px solid #00ff00;
    box-shadow: 0 0 10px rgba(0,255,0,0.3);
}

.inventory-slot.item.equipped::after {
    content: 'EQUIPPED';
    position: absolute;
    top: 5px;
    left: 5px;
    background: #00ff00;
    color: #000;
    font-size: 6px;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 2px;
}

@keyframes casket-glow {
    from { box-shadow: 0 0 5px #f33; }
    to { box-shadow: 0 0 15px #f33; }
}

/* Town View Grid */
.town-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.town-grid.solo {
    grid-template-columns: 1fr;
}

.next-town-preview {
    margin-top: 20px;
    background: linear-gradient(to bottom, #3e2a1c, #2b1810);
    padding: 15px;
    border: 2px solid #6b4423;
    border-radius: 4px;
}

#coin-view {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.mining-target {
    text-align: center;
}

.click-hint {
    display: block;
    margin-top: 10px;
    font-size: 10px;
    color: #aaa;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

.rock-img {
    width: 200px;
    height: 200px;
    image-rendering: auto;
    filter: drop-shadow(0 0 15px #666);
    transition: transform 0.05s;
}

.rock-img:active {
    transform: scale(0.95);
}

/* Town View Styles (World Map) */
.move-town-btn {
    width: 100%;
    display: block;
    padding: 12px;
    background: linear-gradient(to bottom, #ff981f, #e67e22);
    border: 3px solid #b8860b;
    color: #000;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    margin-top: 25px;
    transition: all 0.2s;
    font-weight: bold;
}

.move-town-btn:disabled {
    filter: grayscale(1);
    opacity: 0.6;
    cursor: not-allowed;
}

.move-town-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

#next-town-name {
    font-size: 18px;
    color: #ffd700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 0 #000;
}

#next-town-gps,
#next-town-gpc {
    font-size: 11px;
    color: #8f8;
    margin: 8px 0;
    padding: 5px;
    background: rgba(0, 255, 0, 0.05);
    border-radius: 4px;
    border-left: 3px solid #0f0;
}

.town-requirements {
    background: #2b2318;
    padding: 15px;
    border-radius: 6px;
    border: 2px solid #6b4423;
    margin-top: 15px;
}

.town-requirements h3 {
    color: #ffa500;
    font-size: 14px;
    margin-bottom: 10px;
    text-align: center;
}

.stats-breakdown {
    background: #2b2318;
    padding: 15px;
    border-radius: 6px;
    border: 2px solid #6b4423;
    margin-top: 15px;
}

.stats-breakdown h3 {
    color: #ffd700;
    font-size: 11px;
    margin-bottom: 10px;
    text-align: center;
}

.bonuses-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.bonus-item {
    background: rgba(0, 0, 0, 0.4);
    padding: 8px;
    border-radius: 4px;
    border-left: 3px solid #ffd700;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bonus-item .label {
    font-size: 8px;
    color: #aaa;
}

.bonus-item .value {
    font-size: 9px;
    color: #0f0;
}

.requirement-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 9px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #444;
    border-radius: 4px;
    line-height: 1.4;
    flex-wrap: wrap;
    gap: 5px;
}

.requirement-item.met {
    color: #0f0;
    border: 1px solid #0a0;
}

.world-view-container {
    max-width: 800px;
    margin: 0 auto;
    height: 100%;
    overflow-y: auto;
    padding: 20px 20px 80px 20px;
    box-sizing: border-box;
}

.move-town-btn {
    width: 100%;
    padding: 15px;
    margin: 30px 0;
    background: linear-gradient(to bottom, #4CAF50, #388E3C);
    border: 3px solid #004d00;
    color: #fff;
    font-family: inherit;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    text-transform: uppercase;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    font-family: 'Press Start 2P', cursive;
    line-height: 1.5;
}

.move-town-btn:hover:not(:disabled) {
    background: linear-gradient(to bottom, #66BB6A, #43A047);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.5);
    border-color: #ffd700;
}

.move-town-btn:disabled {
    background: #5d4037;
    border-color: #3e2723;
    color: #7a6a3e;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
    transform: none;
}

.town-header {
    margin-bottom: 45px;
    text-align: center;
}

.town-header h2 {
    margin-bottom: 15px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    font-size: 22px;
}

.town-header p {
    color: #ffd700;
    font-size: 16px;
    opacity: 0.9;
    letter-spacing: 1.5px;
    display: inline-block;
    border-bottom: 2px solid #5d4037;
    padding-bottom: 5px;
}

/* Quest List */
.quest-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quest-item {
    background: #4a3b2a;
    border: 2px solid #2b2318;
    padding: 12px;
    border-radius: 4px;
}

.quest-item.completed {
    border-color: #0f0;
    opacity: 0.8;
}

.quest-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 9px;
}

.quest-bar {
    width: 100%;
    height: 6px;
    background: #2b2318;
    border-radius: 3px;
    overflow: hidden;
}

.quest-fill {
    height: 100%;
    background: #0f0;
    width: 0%;
    transition: width 0.3s;
}

.world-bonuses {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#floating-text-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.floating-text {
    position: absolute;
    color: #00ff00;
    font-size: 20px;
    text-shadow: 1px 1px 0 #000;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    z-index: 10000;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px) scale(1.2);
        opacity: 0;
    }
}

.shop-zone {
    flex: 1;
    background: var(--osrs-panel);
    border: 2px outset #756654;
    padding: 10px;
    display: flex;
    flex-direction: column;
    border-radius: 4px;
}

.shop-tabs {
    display: flex;
    margin-bottom: 10px;
    border-bottom: 2px solid #2b2318;
}

.shop-tab {
    flex: 1;
    background: #3e3529;
    border: 2px solid #2b2318;
    border-bottom: none;
    color: #aaa;
    padding: 8px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    cursor: pointer;
    text-shadow: 1px 1px 0 #000;
}

.shop-tab:hover {
    background: #4e4335;
    color: #fff;
}

.shop-tab.active {
    background: #5b4a35;
    color: #ff981f;
    border-bottom: 2px solid #5b4a35;
    margin-bottom: -2px;
    z-index: 1;
}

.nested-nav-area {
    display: flex;
    flex-direction: column;
    background: #2b2318;
    border: 2px solid #5d4037;
    border-top: none;
    border-radius: 0 0 4px 4px;
    padding: 2px;
}

.sub-tab-container {
    display: flex;
    padding: 3px;
    gap: 3px;
    border-bottom: 1px solid #3e3023;
}

.sub-tab-container:last-child {
    border-bottom: none;
}

.sub-tab {
    flex: 1;
    background: #3e3023;
    border: 1px solid #5d4037;
    color: #aaa;
    padding: 4px;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    text-shadow: 1px 1px 0 #000;
    text-transform: uppercase;
    white-space: nowrap;
}

.sub-tab:hover {
    background: #4e4335;
    color: #fff;
}

.sub-tab.active {
    background: #5d4037;
    color: #ffd700;
    border-color: #ffd700;
}

/* Crafting Settings Grid (2x2) */
.craft-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px;
}

.craft-card {
    display: flex;
    align-items: center;
    background: #3e3023;
    border: 2px solid #5d4037;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.craft-card:hover {
    background: #4e4335;
    border-color: #ff981f;
}

.craft-card.active {
    background: #4a3d29;
    border-color: #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.craft-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: #1a1612;
}

.craft-card-icon {
    width: 40px;
    height: 40px;
    margin-right: 8px;
}

.craft-card-info {
    display: flex;
    flex-direction: column;
}

.craft-card-name {
    font-size: 10px;
    color: #fff;
}

.craft-card-owned {
    font-size: 9px;
    color: #aaa;
}

/* Infusion Settings (4 rows) */
.infusion-row {
    background: #2b2318;
    margin-bottom: 8px;
    border-radius: 4px;
    padding: 6px;
}

.infusion-row-header {
    font-size: 10px;
    color: #fff;
    margin-bottom: 6px;
    padding-left: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.infusion-items {
    display: flex;
    gap: 6px;
}

.infusion-card {
    flex: 1;
    display: flex;
    align-items: center;
    background: #3e3023;
    border: 1px solid #5d4037;
    border-radius: 4px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
}

.infusion-card:hover {
    background: #4e4335;
    border-color: #ff981f;
}

.infusion-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
    background: #1a1612;
}

.infusion-card-icon {
    width: 28px;
    height: 28px;
    margin-right: 6px;
    flex-shrink: 0;
}

.infusion-card-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.infusion-card-name {
    font-size: 8px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.infusion-card-owned {
    font-size: 8px;
    color: #4caf50;
}

.infusion-card-value {
    font-size: 7px;
    color: #ffd700;
}

/* Unlock Prompt (Gated Tabs) */
.unlock-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    background: linear-gradient(135deg, #2b2318 0%, #1a1612 100%);
    border: 2px solid #5d4037;
    border-radius: 8px;
    margin: 20px;
}

.unlock-icon img {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.3));
}

.unlock-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.unlock-title {
    font-size: 16px;
    color: #ffd700;
    margin: 0 0 8px 0;
    text-shadow: 1px 1px 2px #000;
}

.unlock-desc {
    font-size: 11px;
    color: #aaa;
    margin: 0 0 15px 0;
    max-width: 200px;
}

.unlock-cost {
    font-size: 12px;
    padding: 5px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.unlock-cost.affordable {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid #4caf50;
}

.unlock-cost.expensive {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
    border: 1px solid #f44336;
}

.unlock-btn {
    background: linear-gradient(135deg, #ffd700 0%, #ff981f 100%);
    border: none;
    color: #1a1612;
    padding: 10px 25px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}

.unlock-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.unlock-btn.disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
}

.unlock-btn.disabled:hover {
    transform: none;
    box-shadow: none;
}

.unlock-level {
    font-size: 12px;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.unlock-level.met {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
}

.unlock-level.unmet {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

.unlock-costs {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 15px;
}

.unlock-cost-line {
    font-size: 11px;
    color: #ccc;
    text-align: center;
}

.shop-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
    padding-top: 10px;
}

.shop-list::-webkit-scrollbar {
    width: 8px;
}

.shop-list::-webkit-scrollbar-track {
    background: #2b2318;
}

.shop-list::-webkit-scrollbar-thumb {
    background: #5d5244;
}

.upgrade-item {
    display: flex;
    align-items: center;
    background: linear-gradient(to bottom, #4a3b2a, #3e3023);
    border: 2px solid #6b5a45;
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
}

.upgrade-item:hover:not(.disabled):not(.locked) {
    background: linear-gradient(to bottom, #5a4b3a, #4e4033);
    border-color: #8b7a65;
    transform: translateX(2px);
}

.upgrade-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upgrade-item.locked {
    filter: grayscale(1) brightness(0.5);
    cursor: not-allowed;
    border-color: #555;
    background: #1a1a1a;
}

.upgrade-item.locked:hover {
    transform: none;
    background: #1a1a1a;
}

.craft-select-card.locked {
    filter: grayscale(1) brightness(0.6);
    background: #1a1a1a;
    border-color: #444;
    cursor: not-allowed;
    opacity: 0.7;
}

.craft-select-card.locked .craft-name {
    color: #888;
}

.craft-select-card.locked .craft-status {
    color: #ff4444;
}

.upgrade-icon {
    width: 40px;
    height: 40px;
    margin-right: 12px;
    image-rendering: pixelated;
    border: 1px solid #000;
    background: #2b2318;
    object-fit: contain;
}

/* Equipment & Tokens Styles */
.rarity-1 { border-color: #cd7f32 !important; box-shadow: inset 0 0 5px #cd7f32; }
.rarity-2 { border-color: #aaa !important; box-shadow: inset 0 0 5px #aaa; }
.rarity-3 { border-color: #eee !important; box-shadow: inset 0 0 10px rgba(255,255,255,0.2); }
.rarity-4 { border-color: #44f !important; box-shadow: 0 0 10px rgba(68,68,255,0.4); }
.rarity-5 { border-color: #0cc !important; box-shadow: 0 0 15px rgba(0,204,204,0.6); animation: rune-glow 2s infinite alternate; }
.rarity-6 { border-color: #f33 !important; box-shadow: 0 0 20px rgba(255,51,51,0.8); animation: dragon-glow 1s infinite alternate; }

@keyframes rune-glow { 
    from { box-shadow: 0 0 5px #0cc; }
    to { box-shadow: 0 0 20px #0cc; }
}

@keyframes dragon-glow { 
    from { box-shadow: 0 0 10px #f33; }
    to { box-shadow: 0 0 30px #f33; filter: brightness(1.2); }
}

.item-actions {
    display: flex;
    gap: 5px;
}

.item-btn {
    padding: 4px 8px;
    font-size: 9px;
    font-family: inherit;
    cursor: pointer;
    border: 2px solid #000;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
    transition: filter 0.2s, transform 0.1s;
    font-weight: bold;
}

.item-btn:hover { filter: brightness(1.2); }
.item-btn:active { transform: translateY(1px); }
.item-btn.equip { background: #2e7d32; border-color: #1b5e20; }
.item-btn.unequip { background: #c62828; border-color: #b71c1c; }
.item-btn.sell { background: #ef6c00; border-color: #e65100; color: #fff; }
.item-btn.open { background: #1565c0; border-color: #0d47a1; color: #fff; }
.item-btn.disenchant { background: #6a1b9a; border-color: #4a148c; color: #fff; }

.item-passive {
    font-size: 8px;
    color: #4af;
    display: block;
    margin-top: 2px;
}

.empty-msg {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 10px;
    line-height: 1.4;
}

.item-count {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #ffd700;
    color: #000;
    font-size: 8px;
    padding: 2px 4px;
    border-radius: 10px;
    border: 1px solid #000;
    font-weight: bold;
    pointer-events: none;
    z-index: 5;
}

.box-icon {
    position: relative;
    font-size: 32px;
    margin-right: 15px;
    width: 40px;
    height: 40px;
    border: 2px solid #000;
    border-radius: 4px;
    background: #2b2318;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.box-icon.reward { background: linear-gradient(135deg, #cd7f32, #8b4513); }
.box-icon.gems { background: linear-gradient(135deg, #44f, #00008b); border-color: #0cc; }

.slot-icon {
    width: 40px;
    height: 40px;
    margin-right: 12px;
    background: #333;
    border: 2px solid #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #ffd700;
    font-weight: bold;
    border-radius: 4px;
}

.upgrade-item.disabled {
    filter: grayscale(1);
    pointer-events: none;
}

.upgrade-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.upgrade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.upgrade-name {
    color: #ffd700;
    font-size: 11px;
    text-shadow: 1px 1px 0 #000;
}

.upgrade-owned {
    color: #aaa;
    font-size: 9px;
}

.upgrade-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
}

.upgrade-cost {
    color: #ffaa00;
}

.upgrade-coins-mini {
    color: #4af;
}

.upgrade-unlock-req {
    color: #f88;
    font-size: 9px;
}

/* Progress Bar for Milestone System */
.progress-bar-container {
    position: relative;
    width: 100%;
    height: 6px;
    background: #2b2318;
    border-radius: 3px;
    margin: 5px 0;
    border: 1px solid #444;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(to right, #4a90e2, #50c878);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-marker {
    position: absolute;
    top: -2px;
    width: 3px;
    height: 10px;
    background: #ffd700;
    border: 1px solid #000;
    transform: translateX(-50%);
}

.progress-marker:hover::after {
    content: attr(title);
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    white-space: nowrap;
}

.random-event {
    position: absolute;
    width: 50px;
    height: 50px;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s;
}

.random-event:hover {
    transform: scale(1.2);
}

.goblin-thief {
    background-image: url('assets/icon_goblin.png');
    background-size: contain;
    background-repeat: no-repeat;
    filter: drop-shadow(0 0 10px red);
    animation: bounce 0.5s infinite alternate;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-10px);
    }
}

#tooltip {
    position: fixed;
    background: linear-gradient(135deg, rgba(20, 15, 10, 0.98), rgba(40, 30, 20, 0.98));
    color: #fff;
    padding: 15px;
    border-radius: 4px;
    border: 3px double #b3a164;
    font-size: 10px;
    max-width: 280px;
    z-index: 2000;
    display: none;
    pointer-events: none;
    text-shadow: 2px 2px 0 #000;
    box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
}

.tooltip-header {
    color: #ffd700;
    font-weight: bold;
    border-bottom: 2px solid #5d4037;
    padding-bottom: 10px;
    margin-bottom: 12px;
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    text-transform: uppercase;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    line-height: 1.4;
    gap: 25px;
}

.tooltip-row .label {
    color: #aaa;
    letter-spacing: 0.5px;
}

.tooltip-row .value {
    color: #fff;
    font-weight: bold;
}

.tooltip-separator {
    border-top: 1px solid #5d4037;
    margin: 12px 0;
    padding-top: 10px;
    text-align: center;
    color: #ffd700;
    font-size: 8px;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
}

footer {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 8px;
    color: #999;
    border-top: 2px solid var(--osrs-border);
    padding: 10px;
}

.footer-btns {
    display: flex;
    gap: 10px;
}

.test-btn {
    padding: 6px 12px;
    background: linear-gradient(to bottom, #007bff, #0056b3);
    border: 2px solid #0056b3;
    color: #fff;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    border-radius: 4px;
}

#reset-game-btn {
    padding: 6px 12px;
    background: linear-gradient(to bottom, #a00, #600);
    border: 2px solid #c00;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    cursor: pointer;
    border-radius: 4px;
}

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 99999;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    border: 2px solid #555;
    border-radius: 4px;
    font-size: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    animation: toastSlideIn 0.3s ease-out, toastFadeOut 0.5s ease-in forwards 2.5s;
    min-width: 200px;
}

.toast.success { border-color: #0f0; color: #0f0; }
.toast.error { border-color: #f44; color: #f44; }
.toast.info { border-color: #4af; color: #4af; }

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastFadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

@media (max-width: 920px) {
    .game-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    main {
        flex-direction: column;
    }

    .main-zone,
    .shop-zone {
        flex: none;
        height: 50%;
    }
}

/* Level Progress Bar */
.level-progress-container {
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    border-radius: 3px;
    margin: 4px 0 8px 0;
    overflow: hidden;
}

.level-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    transition: width 0.3s ease;
}

.upgrade-item.owned .level-progress-fill {
    background: linear-gradient(90deg, #ffd700, #ffa500);
}

/* Crafting Selection UI */
.craft-selection-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.craft-select-card {
    background: #3e3529;
    border: 2px solid #2b2318;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    position: relative;
}

.craft-select-card:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.craft-select-card.active {
    border-color: #ffd700;
    background: #4a3b2a;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.craft-select-icon {
    width: 20px;
    height: 20px;
    margin: 0 auto 10px auto;
    display: block;
    image-rendering: pixelated;
    transition: transform 0.2s;
    position: absolute;
    top: 10px;
    left: 10px;
}

.craft-select-card:hover .craft-select-icon {
    transform: scale(1.1);
}

.craft-select-card.locked .craft-select-icon {
    filter: grayscale(1) brightness(0.7);
}

.craft-select-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.craft-name {
    font-size: 10px;
    color: #fff;
    font-weight: bold;
}

.craft-owned {
    font-size: 9px;
    color: #ffd700;
}

.craft-status {
    font-size: 8px;
    color: #aaa;
}

.active .craft-status {
    color: #ffd700;
}

.production-separator {
    font-size: 9px;
    color: #ffa500;
    margin: 15px 0 10px 0;
    border-bottom: 2px solid #444;
    padding-bottom: 5px;
}

/* Production Rate Display */
.stat-box .rate {
    display: block;
    font-size: 7px;
    color: #8f8;
    margin-top: 2px;
}

/* Production Progress Bar */
.production-bar {
    width: 100%;
    height: 3px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.production-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    transition: width 0.1s linear;
}

/* Fast production shimmer animation (> 1/sec) */
.production-fill.fast {
    width: 100%;
    background: linear-gradient(
        90deg,
        #4caf50 0%,
        #4caf50 40%,
        #8bc34a 50%,
        #4caf50 60%,
        #4caf50 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    100% { background-position: -200% 0; }
}

.has-tooltip {
    cursor: help;
}


/* Footer & Debug */
footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 2px solid var(--osrs-border);
    text-align: center;
}

.reset-btn {
    background: #8b0000;
    color: #fff;
    border: 2px solid #500;
    padding: 5px 10px;
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    text-transform: uppercase;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.reset-btn:hover {
    opacity: 1;
    background: #a00;
}

/* Database View */
.database-container {
    padding: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 3px double #333;
    border-radius: 4px;
    height: 100%;
    overflow-y: auto;
    text-align: center;
}

.db-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    border-bottom: 1px solid #444;
    padding-bottom: 15px;
}

.db-sub {
    color: #888;
    font-size: 0.8rem;
    margin-top: 5px;
}

.db-actions {
    display: flex;
    gap: 10px;
}

.db-editor-hint {
    background: rgba(30, 30, 60, 0.4);
    border-left: 4px solid #4d4dff;
    padding: 10px 15px;
    margin-bottom: 20px;
    font-size: 0.85rem;
}

.db-editor-hint code {
    color: #00ffff;
}

.db-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.db-item-row {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 12px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    text-align: left;
}

.db-item-row:hover {
    border-color: #555;
}

.db-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.db-item-id {
    font-size: 0.7rem;
    color: #666;
    font-family: monospace;
}

.db-item-name {
    font-weight: bold;
    font-size: 0.9rem;
}

.db-item-stats {
    font-size: 0.8rem;
    color: #aaa;
    background: rgba(0,0,0,0.2);
    padding: 8px;
    border-radius: 3px;
    line-height: 1.4;
}

.db-item-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 5px;
}

.db-btn {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 5px 10px;
    font-size: 0.7rem;
    cursor: pointer;
    border-radius: 2px;
}

.db-btn:hover {
    background: #444;
    border-color: #777;
}

.db-btn.cheat {
    background: #4d0000;
    border-color: #8b0000;
}

.db-btn.cheat:hover {
    background: #600000;
}

.dev-only {
    border-color: #8b0000 !important;
}

/* UI Refinements */
.disabled-upgrade {
    filter: grayscale(0.5);
    opacity: 0.6;
    /* pointer-events: none; REMOVED to stay responsive */
}

.upgrade-item.cannot-afford .upgrade-cost,
.upgrade-item.cannot-buy .upgrade-cost {
    color: #ff4444 !important;
}

.upgrade-item.cannot-afford:not(.locked) {
    background: rgba(255, 68, 68, 0.05);
}

.upgrade-item.owned-upgrade {
    border-color: #4caf50 !important;
    background: rgba(76, 175, 80, 0.1) !important;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.2);
    cursor: default;
    filter: none !important;
    opacity: 1 !important;
}

.upgrade-item.owned-upgrade .upgrade-cost {
    color: #4caf50 !important;
}

/* Re-enable pointer events solely for the check cost button */
.disabled-upgrade .check-cost-btn {
    pointer-events: auto;
    filter: grayscale(0);
    opacity: 1;
    background: #444;
    color: #fff;
    border: 1px solid #666;
    border-radius: 2px;
}
.disabled-upgrade .check-cost-btn:hover {
    background: #555;
    border-color: #888;
}

.check-cost-btn {
    background: #2b2b2b;
    color: #ddd;
    border: 1px solid #444;
    border-radius: 2px;
    transition: all 0.2s;
    margin-right: 5px;
}
.check-cost-btn:hover {
    background: #3a3a3a;
    color: #fff;
    border-color: #666;
}

/* Disenchant Button */
.disenchant-btn {
    width: 100%;
    margin-top: 8px;
    padding: 6px;
    font-size: 11px;
    background: #443322;
    color: #ffd700;
    border: 1px solid #a08040;
    cursor: pointer;
    font-family: inherit;
    text-shadow: 1px 1px #000;
    transition: all 0.2s;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.disenchant-btn:hover {
    background: #554433;
    border-color: #ffd700;
    box-shadow: inset 0 0 5px rgba(255, 215, 0, 0.3);
}

.disenchant-btn:active {
    transform: translateY(1px);
    background: #332211;
}
/* Gemstone & Production Category Styles */
.production-category {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #5d4037;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 25px;
    width: 100%;
    box-sizing: border-box;
}

.category-title {
    color: #ffd700;
    font-size: 14px;
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #5d4037;
    text-shadow: 2px 2px 0 #000;
}

.gem-cutting-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.masterpiece-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

/* Collection Log Styles */
.collection-scroll-container {
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    padding-right: 10px;
    padding-bottom: 20px; /* Space for footer/bottom items */
}

.collection-section {
    margin-bottom: 25px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid #5d4037;
    border-radius: 4px;
    padding: 10px;
}

.collection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}

.collection-title {
    color: #ffd700;
    font-size: 12px;
    text-shadow: 1px 1px 0 #000;
}

.collection-progress {
    color: #aaa;
    font-size: 10px;
    font-family: monospace;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
}

.collection-card {
    background: #2b2318;
    border: 2px solid #5d4037;
    border-radius: 4px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    position: relative;
    cursor: help;
    transition: all 0.2s;
}

.collection-card.locked {
    border-color: #333;
    background: #222;
}

.collection-card.unlocked {
    border-color: #4caf50;
    background: linear-gradient(135deg, #4e402a 0%, #3a301f 100%);
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.2);
}

.card-icon-wrapper {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collection-card .item-icon {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.collection-card.locked .item-icon {
    filter: brightness(0) grayscale(100%);
    opacity: 0.3;
}

.collection-card.unlocked .item-icon {
    filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.5));
}

.collection-card .item-tooltip {
    visibility: hidden;
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #ffd700;
    padding: 8px;
    border-radius: 4px;
    width: 180px;
    z-index: 200;
    text-align: center;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.collection-card:hover .item-tooltip {
    visibility: visible;
}

.collection-card .tooltip-name {
    color: #ffd700;
    font-size: 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid #444;
    padding-bottom: 2px;
}

.collection-card .tooltip-desc {
    color: #aaa;
    font-size: 9px;
    line-height: 1.2;
}

/* --- Welcome Modal --- */
/* --- Welcome Modal (Final Premium V2) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content.osrs-panel {
    width: 440px;
    background: #5b4a35;
    border: 4px solid #3e3529;
    box-shadow: 
        0 0 0 2px #5b4a35, 
        0 0 0 4px #ff981f, /* Outer Gold */
        0 15px 50px rgba(0,0,0,0.9);
    position: relative;
    padding: 2px; /* For the inner border effect */
    text-align: center;
    overflow: hidden;
    animation: modalSlideIn 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.modal-content.osrs-panel::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 1px solid rgba(255, 152, 31, 0.3);
    pointer-events: none;
    z-index: 1;
}

@keyframes modalSlideIn {
    from { transform: translateY(40px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    background: linear-gradient(to bottom, #4a3c2a 0%, #3e3529 100%);
    padding: 20px;
    border-bottom: 3px solid #ff981f;
    position: relative;
    z-index: 2;
}

.modal-header h2 {
    color: #ff981f;
    text-shadow: 2px 2px 0 #000;
    margin: 0;
    font-size: 20px;
    letter-spacing: 3px;
}

.modal-body {
    padding: 40px 30px;
    background: radial-gradient(circle at center, #5b4a35 0%, #4a3c2a 100%);
    position: relative;
    z-index: 2;
}

.modal-body h3 {
    text-transform: uppercase;
    font-size: 14px;
    margin-bottom: 12px;
    color: #ff981f;
}

.modal-body p {
    margin-bottom: 35px;
    font-size: 11px;
    color: #e2e2e2;
    line-height: 1.7;
}

.welcome-options {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.osrs-btn {
    background: linear-gradient(to bottom, #745b3d 0%, #4a3c2a 100%);
    border: 2px solid #2b2318;
    color: #ffd700;
    padding: 16px;
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    cursor: pointer;
    text-shadow: 2px 2px 0 #000;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 5px 0 #2b2318;
    position: relative;
    top: 0;
}

.osrs-btn:hover:not(.disabled) {
    background: linear-gradient(to bottom, #8b6e4a 0%, #5d4a35 100%);
    color: #ffffff;
    border-color: #ff981f;
    top: -3px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 8px 0 #2b2318;
}

.osrs-btn:active:not(.disabled) {
    top: 3px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5), 0 2px 0 #2b2318;
}

.osrs-btn.disabled {
    background: #333;
    border-color: #222;
    color: #666;
    box-shadow: none;
    cursor: not-allowed;
    text-shadow: none;
}

.code-section {
    border-top: 1px solid rgba(255,152,31,0.2);
    padding-top: 30px;
    margin-top: 15px;
}

.osrs-input {
    width: 100%;
    padding: 15px;
    background: #111;
    border: 2px solid #3e3529;
    color: #38ff38;
    font-family: monospace;
    font-size: 15px;
    margin-bottom: 15px;
    text-align: center;
    box-shadow: inset 0 3px 10px rgba(0,0,0,0.9);
    outline: none;
}


.osrs-input:focus {
    border-color: #ff981f;
}

.osrs-input::placeholder {
    color: #444;
}



