* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Courier New', monospace;
    color: #fff;
    overflow: hidden;
}
.tier-common { color: #8B4513; }
.tier-rare { color: #3498db; }
.tier-epic { color: #9b59b6; }
.tier-legendary { color: #f7931a; }
.shop-accent-consumable { color: #2ecc71; }
.shop-accent-service { color: #e74c3c; }
.shop-accent-utility { color: #ffd6a1; }
.startup-error {
    position: fixed;
    left: 12px;
    top: 12px;
    max-width: 70vw;
    padding: 8px 10px;
    background: rgba(120, 0, 0, 0.92);
    color: #fff;
    font: 12px monospace;
    z-index: 99999;
    white-space: pre-wrap;
}
#nostr-auth-panel {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1200;
    min-width: 220px;
    padding: 8px;
    border: 1px solid #3a3f4d;
    border-radius: 10px;
    background: linear-gradient(180deg, #1d2027, #121419);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.38);
    color: #cfd6e4;
    font-family: 'Courier New', monospace;
}
.nostr-auth-title {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: bold;
}
.nostr-auth-status {
    margin-bottom: 8px;
    font-size: 11px;
    opacity: 0.92;
}
.nostr-auth-actions {
    display: flex;
    gap: 6px;
}
.nostr-auth-button {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #4b5264;
    border-radius: 8px;
    background: linear-gradient(180deg, #2a3040, #1a1f2c);
    color: #dbe6ff;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
}
.nostr-auth-hint {
    margin-top: 6px;
    font-size: 10px;
    opacity: 0.7;
}
#game-container {
    position: relative;
    cursor: crosshair;
    --game-scale: 1.25;
    transform: scale(var(--game-scale));
    transform-origin: center center;
}
@media (max-width: 1100px), (max-height: 820px) {
    #game-container { --game-scale: 1.08; }
}
@media (max-width: 920px), (max-height: 720px) {
    #game-container { --game-scale: 0.92; }
}

:root {
    --shop-gold: #f0b458;
    --shop-gold-strong: #ffd48a;
    --shop-ink: #0d0f15;
    --shop-panel: #141927;
    --shop-panel-2: #1b2233;
    --shop-line: #2d364d;
    --shop-soft: #8f9ab4;
}

/* Shop overlay */
#shop-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background:
        radial-gradient(1000px 500px at 50% -12%, rgba(240, 180, 88, 0.16), transparent 60%),
        radial-gradient(700px 420px at 10% 100%, rgba(122, 164, 255, 0.09), transparent 60%),
        rgba(7, 8, 12, 0.92);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 24px;
}
#shop-overlay.active { display: flex; }
#shop-overlay h2 {
    color: var(--shop-gold-strong);
    font-size: 26px;
    letter-spacing: 0.11em;
    margin-bottom: 6px;
    text-transform: uppercase;
    text-shadow: 0 1px 0 #000, 0 0 16px rgba(247, 147, 26, 0.25);
}
#shop-panel {
    width: min(1120px, 98%);
    max-height: 96%;
    overflow: hidden;
    border: 1px solid var(--shop-line);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(30, 36, 53, 0.96), rgba(18, 22, 34, 0.96));
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    padding: 20px 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
#shop-subtitle {
    color: var(--shop-soft);
    font-size: 11px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 2px;
}
#shop-balance-row {
    color: #dce6ff;
    font-size: 12px;
    font-weight: bold;
    padding: 8px 12px;
    border: 1px solid #2f4368;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(20, 30, 47, 0.95), rgba(15, 24, 38, 0.95));
    text-align: center;
}
#shop-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
    flex-wrap: wrap;
}
.shop-tab {
    background: linear-gradient(180deg, #232a3d, #1a2030);
    border: 1px solid #313b56;
    color: #aab5cf;
    padding: 7px 14px;
    cursor: pointer;
    font-family: 'Courier New';
    font-size: 11px;
    letter-spacing: 0.04em;
    border-radius: 999px;
    text-transform: uppercase;
    transition: transform 0.12s ease, border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.shop-tab:hover {
    border-color: #55668e;
    color: #dbe7ff;
    transform: translateY(-1px);
}
.shop-tab.active {
    border-color: #8f7143;
    color: #ffe4b8;
    background: linear-gradient(180deg, #3c3120, #2e261a);
    box-shadow: inset 0 0 0 1px rgba(255, 211, 145, 0.17);
}
#shop-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 12px;
    max-height: 560px;
    overflow-y: auto;
    padding: 3px 4px 3px 1px;
    width: 100%;
}
.shop-item {
    background: linear-gradient(180deg, #1d2436, #171d2b);
    border: 1px solid #33405d;
    padding: 10px 12px;
    cursor: default;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    color: #eef3ff;
    font-size: 13px;
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.shop-item:hover {
    border-color: #4f6ca1;
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}
.shop-item.owned {
    border-color: #3d3f4a;
    opacity: 0.56;
    cursor: default;
    filter: saturate(0.78);
}
.shop-item.selected {
    border-color: #d1a660;
    box-shadow: 0 0 0 1px rgba(209, 166, 96, 0.22), 0 8px 22px rgba(0, 0, 0, 0.28);
}
.shop-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}
.shop-name-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.shop-tier-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 9px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 1px 6px;
    opacity: 0.9;
    white-space: nowrap;
}
.shop-price {
    color: var(--shop-gold);
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    text-shadow: 0 1px 0 #000;
}
.shop-desc {
    color: #99a6c8;
    font-size: 12px;
    width: 100%;
    line-height: 1.35;
}
.shop-status {
    color: #8f96ab;
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.shop-actions {
    display: flex;
    gap: 6px;
    margin-top: 7px;
    width: 100%;
}
.shop-buy-btn {
    border: 1px solid transparent;
    padding: 6px 9px;
    font-size: 10px;
    border-radius: 9px;
    letter-spacing: 0.03em;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: transform 0.11s ease, filter 0.11s ease, border-color 0.11s ease, box-shadow 0.11s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    flex: 1;
    font-weight: bold;
    text-transform: uppercase;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.shop-buy-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
.shop-buy-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
    box-shadow: none;
}
.shop-buy-btn.sats {
    background: linear-gradient(180deg, #2a3f62, #1a2a44);
    border-color: #5075ab;
    color: #d7e8ff;
    box-shadow: inset 0 1px 0 rgba(180, 214, 255, 0.22);
}
.shop-buy-btn.shekels {
    background: linear-gradient(180deg, #4d3722, #362717);
    border-color: #9a7344;
    color: #ffe0a7;
    box-shadow: inset 0 1px 0 rgba(255, 232, 181, 0.2);
}
.shop-buy-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    line-height: 1;
    flex: 0 0 16px;
}
.shop-buy-btn.sats .shop-buy-icon {
    background: radial-gradient(circle at 35% 30%, #ffe0b0 0%, #f7931a 58%, #aa5e00 100%);
    color: #fff7e4;
    border: 1px solid rgba(255, 207, 126, 0.7);
    font-weight: bold;
}
.shop-buy-btn.shekels .shop-buy-icon {
    background: radial-gradient(circle at 35% 30%, #fff2c8 0%, #e2b245 56%, #8f6621 100%);
    border: 1px solid rgba(255, 224, 143, 0.72);
    box-shadow: inset 0 0 0 1px rgba(120, 82, 20, 0.35);
    position: relative;
}
.shop-buy-btn.shekels .shop-buy-icon::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(140, 95, 24, 0.6);
    position: absolute;
}
.shop-buy-text {
    opacity: 0.92;
    font-size: 10px;
    letter-spacing: 0.06em;
}
.shop-buy-amount {
    font-size: 13px;
    color: #fff;
}
#shop-items::-webkit-scrollbar { width: 9px; }
#shop-items::-webkit-scrollbar-track {
    background: rgba(10, 12, 19, 0.7);
    border-radius: 8px;
}
#shop-items::-webkit-scrollbar-thumb {
    background: #354562;
    border: 1px solid #2a344b;
    border-radius: 8px;
}
#shop-items::-webkit-scrollbar-thumb:hover { background: #455b82; }
#shop-info-card {
    margin-top: 2px;
    border: 1px solid #3a4563;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(23, 29, 43, 0.96), rgba(16, 21, 33, 0.96));
    padding: 10px 12px;
    min-height: 150px;
    color: #c9d4f0;
    font-size: 12px;
}
#shop-info-card .info-empty {
    color: #7f8bad;
}
#shop-info-card .info-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}
#shop-info-card .info-name {
    font-size: 13px;
    font-weight: bold;
}
#shop-info-card .info-tier {
    font-size: 10px;
    padding: 1px 7px;
    border: 1px solid currentColor;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
#shop-info-card .info-desc {
    color: #aeb8d4;
    margin-bottom: 6px;
}
#shop-info-card .info-stats {
    color: #d7e3ff;
    line-height: 1.35;
    margin-bottom: 4px;
}
#shop-info-card .info-type {
    color: #8ea0ca;
    margin-bottom: 2px;
}
#shop-info-card .info-prices {
    color: #f3ce8e;
}
#shop-close {
    margin-top: 2px;
    align-self: center;
    background: linear-gradient(180deg, #222738, #1a2030);
    border: 1px solid #42506f;
    color: #c8d4f0;
    padding: 10px 28px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 999px;
    transition: transform 0.11s ease, border-color 0.11s ease;
}
#shop-close:hover {
    color: #fff;
    border-color: #7a8ebd;
    transform: translateY(-1px);
}

/* QR overlay */
#qr-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 200;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
#qr-overlay.active { display: flex; }
#qr-overlay h2 {
    color: #f7931a;
    font-size: 20px;
    margin-bottom: 8px;
}
#qr-overlay p {
    color: #aaa;
    font-size: 14px;
    margin-bottom: 16px;
}
#qr-canvas { margin-bottom: 16px; }
#payment-status {
    color: #f7931a;
    font-size: 16px;
    margin-top: 8px;
}
#qr-cancel {
    margin-top: 16px;
    background: none;
    border: 1px solid #666;
    color: #666;
    padding: 8px 16px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
}
#qr-cancel:hover { color: #fff; border-color: #fff; }

/* Grid Inventory overlay */
#inventory-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 150;
    font-family: 'Courier New', monospace;
    color: #fff;
}
#inventory-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
    align-content: center;
    flex-wrap: nowrap;
    gap: 10px 14px;
    padding: 8px 10px;
    box-sizing: border-box;
    overflow: hidden;
}

#inv-equip { display: flex; flex-direction: column; gap: 4px; align-items: center; }
#inv-equip .equip-slot {
    width: 52px; height: 52px;
    border: 2px solid #444; background: #1a1a1a;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative;
}
#inv-equip .equip-slot:hover { border-color: #888; }
#inv-equip .equip-slot.small { width: 32px; height: 32px; }
.equip-slot-hidden { display: none !important; }
.equip-label { color: #666; font-size: 9px; text-transform: uppercase; line-height: 1; }
.equip-item { font-size: 11px; text-align: center; padding: 2px; }
.equip-name { font-size: 8px; }
.equip-placeholder { color: #333; font-size: 8px; }
.equip-count { color: #aaa; font-size: 9px; }
.equip-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    image-rendering: pixelated;
}
.equip-slot-icon {
    width: 28px;
    height: 28px;
    opacity: 0.3;
    image-rendering: pixelated;
}

#inv-grid-panel { position: relative; flex: 0 0 auto; }
#inv-grid, #stash-grid {
    display: grid;
    grid-template-columns: repeat(4, 42px);
    grid-template-rows: repeat(8, 42px);
    gap: 1px;
    background: #333;
    border: 2px solid #555;
    padding: 1px;
    position: relative;
}
.grid-cell { width: 42px; height: 42px; background: #1a1a1a; }
.grid-item {
    position: absolute;
    border: 1px solid;
    background: #222;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    text-align: center;
    overflow: hidden;
    z-index: 10;
    user-select: none;
    line-height: 1.1;
    padding: 1px;
    transition: left 90ms cubic-bezier(0.2, 0.8, 0.2, 1), top 90ms cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: left, top;
}
.grid-item.dragging { transition: none; }
.grid-item:hover { filter: brightness(1.3); }
.grid-item .stack-count {
    position: absolute; bottom: 1px; right: 2px;
    font-size: 9px; color: #fff; font-weight: bold;
    text-shadow: 1px 1px 0 #000;
}
#inv-stats-panel {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #aaa;
    min-width: 190px;
    max-width: 240px;
}
#inv-stats-panel .stat-line { margin: 2px 0; }
#inv-tooltip {
    display: none; position: absolute;
    background: #111; border: 1px solid #666;
    padding: 8px; font-size: 11px; color: #ccc;
    z-index: 200; pointer-events: none; max-width: 160px;
}
.tooltip-title { font-weight: bold; }
.tooltip-meta { color: #888; font-size: 10px; }
.tooltip-desc { margin-top: 4px; }
.tooltip-size { color: #666; font-size: 9px; margin-top: 4px; }
#menu-name-tooltip {
    display: none;
    position: absolute;
    background: rgba(12, 12, 12, 0.95);
    border: 1px solid #888;
    color: #ddd;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 240;
    pointer-events: none;
    font-family: 'Courier New', monospace;
    white-space: nowrap;
}
#inv-controls {
    color: #555;
    font-size: 11px;
    margin-top: 4px;
    text-align: center;
    flex: 1 1 100%;
    order: 20;
}
@media (max-width: 980px) {
    #inventory-overlay.active {
        justify-content: center;
        gap: 12px;
    }
    #inv-stats-panel {
        min-width: 0;
        max-width: 320px;
        flex: 1 1 100%;
        order: 15;
    }
    #inv-controls {
        margin-top: 0;
    }
}
#drag-ghost {
    display: none; position: absolute;
    z-index: 300; pointer-events: none; opacity: 0.8;
}

/* Stash overlay */
#stash-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.92);
    z-index: 160;
    font-family: 'Courier New', monospace;
    color: #fff;
}
#stash-overlay.active {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 8px 20px;
    overflow: hidden;
}
#stash-panel {
    width: max-content;
    min-width: 460px;
    max-height: calc(100% - 12px);
    display: flex;
    flex-direction: column;
    overflow: visible;
}
.stash-header-row,
.stash-sell-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.stash-header-row { margin-bottom: 8px; }
.stash-sell-row { margin: 8px 0; }
.stash-title {
    color: #f7931a;
    font-family: 'Courier New', monospace;
    margin: 0;
}
.stash-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
#stash-shekel-balance {
    color: #d1b26d;
    font-size: 11px;
}
#stash-sell-btn {
    background: #2a2014;
    border: 1px solid #8a6a3b;
    color: #f5d18c;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
}
.stash-sell-row #stash-sell-btn {
    padding: 6px 12px;
    font-size: 12px;
}
#stash-sell-btn.active {
    border-color: #f5d18c;
    color: #fff2cc;
    background: #5a2f16;
}
.stash-help {
    color: #777;
    font-size: 10px;
    margin-bottom: 8px;
}
#stash-backpack {
    flex: 0 0 auto;
    margin-top: 2px;
    margin-left: 10px;
}
.stash-backpack-title {
    color: #aaa;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}
#stash-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
#stash-tabs button {
    background: #222; border: 1px solid #555; color: #888;
    padding: 4px 12px; cursor: pointer; font-family: 'Courier New'; font-size: 11px;
}
#stash-tabs button.active { border-color: #f7931a; color: #f7931a; }
#stash-storage-grid {
    min-height: 0;
    max-height: none;
    overflow: visible;
    display: grid;
    gap: 1px;
    background: #333;
    border: 2px solid #555;
    padding: 1px;
    position: relative;
    width: fit-content;
    box-sizing: content-box;
}
.stash-grid-item:hover { filter: brightness(1.25); }
.stash-empty {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #555;
    font-size: 12px;
    pointer-events: none;
}
#stash-item-card {
    margin-top: 10px;
    height: 110px;
    overflow-y: auto;
    box-sizing: border-box;
    border: 1px solid #444;
    background: #111;
    padding: 8px;
    color: #aaa;
    font-size: 11px;
    line-height: 1.35;
    font-family: 'Courier New', monospace;
}
.stash-card-empty { color: #666; }
.stash-card-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}
.stash-card-title-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.stash-card-item-name {
    font-size: 13px;
    font-weight: bold;
}
.stash-card-tier {
    font-size: 10px;
    white-space: nowrap;
}
.stash-card-type {
    color: #888;
    font-size: 10px;
    margin-top: 2px;
}
.stash-card-desc {
    color: #aaa;
    margin-top: 6px;
}
.stash-card-stats {
    margin-top: 6px;
    color: #ccc;
}
.stash-card-facts,
.stash-card-prices {
    display: flex;
    justify-content: space-between;
    color: #777;
    font-size: 10px;
}
.stash-card-facts { margin-top: 8px; }
.stash-card-prices {
    margin-top: 4px;
    color: #8f8f8f;
}
.stash-card-stack { color: #aaa; }
.stash-action-btn {
    background: #2a2014;
    border: 1px solid #8a6a3b;
    color: #f5d18c;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
}
.stash-action-btn-all {
    background: #3a2014;
    border-color: #b06a3b;
    color: #ffd8b2;
}
#stash-close {
    margin-top: 12px; background: none; border: 1px solid #666;
    color: #666; padding: 6px 14px; cursor: pointer; font-family: 'Courier New';
}
#stash-close:hover { color: #fff; border-color: #fff; }

/* Pause menu */
#pause-overlay {
    display: none; position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; background: rgba(0,0,0,0.85);
    z-index: 250; font-family: 'Courier New', monospace; color: #fff;
}
#pause-overlay.active { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
#pause-overlay h2 { color: #f7931a; font-size: 28px; margin-bottom: 16px; }
.pause-btn {
    background: #1a1a2e; border: 2px solid #555; color: #ccc;
    padding: 12px 40px; cursor: pointer; font-family: 'Courier New';
    font-size: 16px; min-width: 200px; text-align: center;
}
.pause-btn:hover { border-color: #f7931a; color: #f7931a; }
.pause-btn.quit:hover { border-color: #e74c3c; color: #e74c3c; }
#settings-panel {
    display: none;
    margin-top: 10px;
    padding: 12px 14px;
    width: 320px;
    border: 1px solid #444;
    background: #0f0f17;
}
#settings-panel.active { display: block; }
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 8px 0;
    color: #aaa;
    font-size: 12px;
}
.settings-row input[type="range"] { width: 160px; }
#settings-close {
    margin-top: 8px;
    width: 100%;
    background: none;
    border: 1px solid #666;
    color: #aaa;
    padding: 6px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
}
#settings-close:hover { border-color: #fff; color: #fff; }

/* Item discovery card */
/* Encounter overlay */
#encounter-overlay {
    display: none; position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; background: rgba(0,0,0,0.9);
    z-index: 240; font-family: 'Courier New', monospace; color: #fff;
}
#encounter-overlay.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#enc-title { color: #f7931a; font-size: 20px; font-weight: bold; margin-bottom: 8px; }
#enc-intro { color: #aaa; font-size: 12px; max-width: 400px; text-align: center; margin-bottom: 12px; }
#enc-dialogue { color: #fff; font-size: 14px; max-width: 400px; text-align: center; margin-bottom: 20px; font-style: italic; }
#enc-choices { display: flex; flex-direction: column; gap: 8px; width: 360px; }
.enc-choice {
    background: #1a1a2e; border: 1px solid #555; color: #ccc; padding: 10px 16px;
    cursor: pointer; font-family: 'Courier New'; font-size: 13px; text-align: left;
    display: flex; flex-direction: column; gap: 2px;
}
.enc-choice:hover { border-color: #f7931a; color: #fff; }
.enc-choice.disabled { opacity: 0.4; cursor: default; }
.enc-choice.disabled:hover { border-color: #555; color: #ccc; }
.enc-choice-label { font-weight: bold; }
.enc-choice-desc { font-size: 10px; color: #888; }

/* Notification popup (top-left) */
#notify-popup {
    display: none; position: absolute; top: 12px; left: 12px;
    background: #111; border: 2px solid #2ecc71; padding: 10px 16px;
    z-index: 270; font-family: 'Courier New'; color: #fff;
    font-size: 12px; max-width: 280px; border-radius: 4px;
    animation: notifySlide 0.3s ease-out;
}
#notify-popup.active { display: block; }
#notify-popup.purchase { border-color: #f7931a; }
#notify-popup .notify-title { font-weight: bold; margin-bottom: 4px; }
#notify-popup .notify-items { color: #aaa; font-size: 11px; }
@keyframes notifySlide { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* HUD bars */
#hud-bars {
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 12px; z-index: 90;
    pointer-events: none;
}
#hud-active-weapon {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 91;
    pointer-events: none;
    font-family: 'Courier New', monospace;
    color: #cfd6e4;
    font-size: 11px;
    text-shadow: 0 1px 0 #000;
}
#hud-quick-consumable {
    position: absolute;
    bottom: 40px;
    left: calc(50% + 180px);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 91;
    pointer-events: none;
    font-family: 'Courier New', monospace;
    color: #cfd6e4;
    font-size: 11px;
    text-shadow: 0 1px 0 #000;
}
#hud-weapon-icon {
    display: none;
    width: 18px;
    height: 18px;
    image-rendering: pixelated;
    object-fit: contain;
    border: 1px solid #3e4558;
    background: rgba(16, 20, 31, 0.85);
    border-radius: 3px;
    padding: 1px;
}
#hud-potion-icon {
    width: 18px;
    height: 18px;
    image-rendering: pixelated;
    object-fit: contain;
    border: 1px solid #4b4551;
    background: rgba(27, 18, 29, 0.9);
    border-radius: 3px;
    padding: 1px;
}
.hud-bar-container { display: flex; align-items: center; gap: 4px; }
.hud-bar-label { font-family: 'Courier New'; font-size: 10px; color: #888; min-width: 26px; }
.hud-bar-bg { width: 80px; height: 10px; background: #222; border: 1px solid #444; border-radius: 2px; overflow: hidden; }
.hud-bar-fill { height: 100%; transition: width 0.15s; border-radius: 1px; }
.hud-bar-fill.hp { background: #e74c3c; }
.hud-bar-fill.stm { background: #2ecc71; }
.hud-bar-fill.mp { background: #3498db; }
.hud-bar-value { font-family: 'Courier New'; font-size: 9px; color: #aaa; min-width: 30px; }
.hud-gold-label,
.hud-gold-value { color: #d1b26d; }
.hud-gold-value { min-width: 40px; }
.hud-xp-wrap {
    position: absolute;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 92;
    min-width: 260px;
    text-align: center;
    pointer-events: none;
}
#hud-level {
    color: #b7cbff;
    font-family: 'Courier New';
    font-size: 11px;
    margin-bottom: 3px;
}
#hud-xp-bg {
    width: 260px;
    height: 8px;
    border: 1px solid #4a5674;
    background: #1b2233;
    border-radius: 999px;
    overflow: hidden;
    margin: 0 auto;
}
#hud-xp-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #6ea2ff, #9f7dff);
    transition: width 0.2s;
}
#hud-perk-points {
    color: #f4d094;
    font-family: 'Courier New';
    font-size: 10px;
    margin-top: 3px;
}

#discovery-card {
    display: none; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #111; border: 2px solid #f7931a; padding: 20px;
    z-index: 260; font-family: 'Courier New'; color: #fff;
    text-align: center; min-width: 200px;
}
#discovery-card.active { display: block; }
#discovery-card img { image-rendering: pixelated; margin: 8px auto; display: block; }
#discovery-card .card-name { font-size: 16px; font-weight: bold; margin-bottom: 4px; }
#discovery-card .card-tier { font-size: 11px; margin-bottom: 8px; }
#discovery-card .card-desc { font-size: 12px; color: #aaa; }
#discovery-card .card-dismiss { font-size: 10px; color: #555; margin-top: 12px; }

/* Extraction progress bar */
#extract-bar {
    display: none;
    position: absolute;
    bottom: 60px; left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    text-align: center;
}
#extract-bar.active { display: block; }
#extract-label { color: #2ecc71; font-size: 16px; font-family: 'Courier New'; font-weight: bold; margin-bottom: 4px; }
#extract-progress {
    width: 200px; height: 8px;
    background: #333; border-radius: 4px; overflow: hidden;
}
#extract-fill {
    width: 0%; height: 100%;
    background: #2ecc71;
    transition: width 0.1s;
}

/* Perk tree */
#perk-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 190;
    align-items: center;
    justify-content: center;
}
#perk-overlay.active { display: flex; }
#perk-panel {
    width: 1000px;
    max-width: 96%;
    max-height: 90%;
    overflow: hidden;
    border: 1px solid #4d5a7d;
    border-radius: 16px;
    background:
        radial-gradient(1200px 600px at 50% -20%, rgba(120, 160, 255, 0.12), transparent 60%),
        radial-gradient(700px 400px at 0% 100%, rgba(240, 195, 120, 0.08), transparent 65%),
        linear-gradient(180deg, #171d2c, #111622);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
#perk-panel h2 {
    font-size: 24px;
    color: #ffe0ae;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 0 #000, 0 0 12px rgba(255, 208, 140, 0.2);
}
.perk-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
#perk-exit {
    border: 1px solid #6a7ca8;
    background: #222b40;
    color: #dbe7ff;
    border-radius: 8px;
    padding: 6px 10px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    cursor: pointer;
}
#perk-balance {
    color: #f2cf8b;
    font-size: 12px;
    border: 1px solid #86683f;
    background: rgba(70, 52, 24, 0.35);
    border-radius: 8px;
    padding: 6px 10px;
    width: fit-content;
}
#perk-tabs { display: flex; gap: 10px; }
.perk-tab {
    border: 1px solid #4f608c;
    border-radius: 999px;
    background: linear-gradient(180deg, #28324c, #1d263c);
    color: #c4d3ff;
    font-size: 14px;
    padding: 10px 18px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 150px;
    font-weight: bold;
}
.perk-tab.active {
    color: #ffe7bf;
    border-color: #9a7a4a;
    background: linear-gradient(180deg, #443523, #33281c);
    box-shadow: inset 0 0 0 1px rgba(255, 220, 170, 0.18);
}
#perk-tree {
    overflow-y: auto;
    padding-right: 4px;
    min-height: 360px;
}
.perk-tree-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    position: relative;
}
.perk-col {
    border: 1px solid #33415f;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(29, 37, 56, 0.92), rgba(20, 27, 43, 0.92));
    padding: 10px;
    position: relative;
    overflow: hidden;
}
.perk-col::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(420px 120px at 50% -40%, rgba(160, 190, 255, 0.08), transparent 70%);
    pointer-events: none;
}
.perk-col-title {
    color: #dce8ff;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 8px;
}
.perk-lane {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}
.perk-lane::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 14px;
    bottom: 14px;
    width: 2px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, rgba(120, 145, 200, 0.45), rgba(120, 145, 200, 0.1));
    z-index: 0;
}
.perk-node {
    position: relative;
    z-index: 1;
    border: 1px solid #42547d;
    border-radius: 10px;
    background: linear-gradient(180deg, #232d44, #1b2437);
    padding: 9px;
    transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.perk-node:hover {
    border-color: #627db6;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}
.perk-node.unlocked {
    border-color: #6f8ed1;
    box-shadow: inset 0 0 0 1px rgba(126, 159, 224, 0.2);
}
.perk-node.maxed {
    border-color: #a28657;
    background: linear-gradient(180deg, #3a3022, #2d251b);
}
.perk-node .perk-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.perk-node .perk-name {
    color: #dce7ff;
    font-size: 13px;
    font-weight: bold;
}
.perk-level { color: #92a8d8; font-size: 11px; }
.perk-desc { color: #9aa9cd; font-size: 11px; margin-top: 4px; }
.perk-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}
.perk-cost { color: #f2cf8b; font-size: 11px; }
.perk-buy {
    border: 1px solid #5a73ad;
    border-radius: 7px;
    background: linear-gradient(180deg, #2c3d62, #22304e);
    color: #dfebff;
    font-size: 11px;
    padding: 5px 10px;
    cursor: pointer;
}
.perk-buy:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
#perk-close {
    margin-top: 2px;
    align-self: center;
    border: 1px solid #5a6b96;
    border-radius: 999px;
    background: #212a40;
    color: #d2def8;
    font-size: 12px;
    padding: 8px 18px;
    cursor: pointer;
}

/* Theme colors per branch */
#perk-panel[data-tree="movement"] .perk-col-title { color: #b9f2c5; }
#perk-panel[data-tree="movement"] .perk-lane::before { background: linear-gradient(180deg, rgba(90, 191, 120, 0.6), rgba(90, 191, 120, 0.18)); }
#perk-panel[data-tree="movement"] .perk-node.unlocked { border-color: #4ea56b; box-shadow: inset 0 0 0 1px rgba(120, 220, 150, 0.2); }
#perk-panel[data-tree="movement"] .perk-tab.active { border-color: #4ea56b; background: linear-gradient(180deg, #274432, #1e3327); color: #cff7da; }

#perk-panel[data-tree="damage"] .perk-col-title { color: #ffc0c0; }
#perk-panel[data-tree="damage"] .perk-lane::before { background: linear-gradient(180deg, rgba(205, 85, 85, 0.62), rgba(205, 85, 85, 0.18)); }
#perk-panel[data-tree="damage"] .perk-node.unlocked { border-color: #b75c5c; box-shadow: inset 0 0 0 1px rgba(231, 122, 122, 0.2); }
#perk-panel[data-tree="damage"] .perk-tab.active { border-color: #b75c5c; background: linear-gradient(180deg, #4c2a2a, #3a2020); color: #ffd3d3; }

#perk-panel[data-tree="magic"] .perk-col-title { color: #d2c5ff; }
#perk-panel[data-tree="magic"] .perk-lane::before { background: linear-gradient(180deg, rgba(134, 104, 220, 0.62), rgba(134, 104, 220, 0.2)); }
#perk-panel[data-tree="magic"] .perk-node.unlocked { border-color: #7a66cf; box-shadow: inset 0 0 0 1px rgba(165, 141, 245, 0.2); }
#perk-panel[data-tree="magic"] .perk-tab.active { border-color: #7a66cf; background: linear-gradient(180deg, #352b58, #292146); color: #e2d8ff; }

@media (max-width: 1000px) {
    .perk-tree-grid { grid-template-columns: 1fr; }
    #perk-tree { min-height: 280px; }
    .perk-tab { min-width: 0; flex: 1; font-size: 12px; padding: 8px 10px; }
}

.shop-icon {
    width: 34px;
    height: 34px;
    image-rendering: pixelated;
    border: 1px solid #425276;
    background: #111521;
    border-radius: 6px;
    flex: 0 0 34px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.shop-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    flex: 1;
    min-width: 0;
}
.shop-title-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
@media (max-width: 900px), (max-height: 760px) {
    #shop-panel {
        width: 96%;
        max-height: 93%;
        padding: 12px;
    }
    #shop-items {
        grid-template-columns: 1fr;
        max-height: 420px;
    }
}
