/* Modal system — dark RPG panel style */

/* --- Overlay --- */
.modal-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 4, 8, 0.66);
    backdrop-filter: blur(4px);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

/* --- Panel --- */
.modal {
    background: linear-gradient(180deg, #17151f 0%, #0c0b10 100%);
    border: 1px solid #2e2a22;
    border-radius: 10px;
    padding: 0;
    width: 96vw;
    max-width: 1100px;
    height: 82vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.7),
                0 0 0 1px rgba(196,163,90,0.04),
                inset 0 1px 0 rgba(255,255,255,0.03);
}

/* --- Header --- */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 22px;
    background: linear-gradient(180deg, rgba(196,163,90,0.08), transparent 80%);
    border-bottom: 1px solid #262219;
    flex-shrink: 0;
}

.modal-header h2 {
    font-family: 'Cinzel', serif;
    color: #e4d8b0;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: rgba(24, 22, 18, 0.6);
    border: 1px solid #2a2520;
    border-radius: 50%;
    color: #8a7a5a;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.modal-close:hover {
    color: #e4d8b0;
    border-color: #7a6a3a;
    background: rgba(196,163,90,0.08);
}

/* --- Content area --- */
.modal-body {
    padding: 16px 20px 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-body.modal-stub {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #6a6050;
    font-size: 14px;
    font-style: italic;
    padding: 40px;
}

/* Equipment modal: fixed top sections, scrollable inventory */
.equip-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.equip-fixed {
    flex-shrink: 0;
}

.equip-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.equip-body {
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Item detail popover */
.item-detail-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10;
    justify-content: center;
    align-items: center;
}

.item-detail-overlay.open {
    display: flex;
}

.item-detail-card {
    background: linear-gradient(180deg, #1a1714, #121010);
    border: 2px solid #4a4030;
    border-radius: 4px;
    padding: 18px 20px;
    min-width: 400px;
    max-width: 520px;
    width: 90%;
    max-height: 85%;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 30px rgba(0,0,0,0.7);
}

.detail-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: #5a5040;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

.detail-close:hover {
    color: #c4a35a;
}

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

.detail-icon {
    width: 44px;
    height: 44px;
    border: 2px solid #3a3428;
    border-radius: 4px;
    background: rgba(20,18,14,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.detail-name {
    font-family: 'Cinzel', serif;
    font-size: 15px;
    font-weight: 700;
}

.detail-meta {
    font-size: 11px;
    margin-top: 1px;
}

.detail-skill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    font-size: 12px;
}

.detail-skill-label {
    color: #5a5040;
}

.detail-skill-name {
    color: #c4a35a;
    font-weight: 600;
}

.detail-skill-cd {
    color: #6a6050;
    font-size: 11px;
}

.detail-comp-header {
    display: grid;
    grid-template-columns: 1fr 60px 70px;
    gap: 4px;
    font-size: 10px;
    color: #4a4538;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 4px;
}

.detail-comp-row {
    display: grid;
    grid-template-columns: 1fr 60px 70px;
    gap: 4px;
    padding: 2px 0;
    font-size: 12px;
}

.detail-comp-label {
    color: #6a6050;
}

.detail-comp-val {
    text-align: right;
    color: #a8a090;
}

.detail-comp-diff {
    text-align: right;
}

.detail-diff-up {
    color: #1eff00;
}

.detail-diff-down {
    color: #ff4444;
}

.detail-diff-same {
    color: #a8a090;
}

/* =========================================
   CRAFTING MODAL
   ========================================= */

.craft-mat-bar {
    display: flex;
    gap: 14px;
    padding: 10px 12px;
    background: rgba(196,163,90,0.03);
    border: 1px solid #2a2520;
    border-radius: 3px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.craft-mat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #a8a090;
}

.craft-mat-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    -webkit-mask-size: contain;
            mask-size: contain;
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-position: center;
            mask-position: center;
}

.mat-scraps { background-color: #8a7a5a; -webkit-mask-image: url('../assets/icons/crafting/scraps.svg');       mask-image: url('../assets/icons/crafting/scraps.svg'); }
.mat-rare   { background-color: #0070ff; -webkit-mask-image: url('../assets/icons/crafting/ether_dust.svg');   mask-image: url('../assets/icons/crafting/ether_dust.svg'); }
.mat-epic   { background-color: #a335ee; -webkit-mask-image: url('../assets/icons/crafting/soul_ember.svg');   mask-image: url('../assets/icons/crafting/soul_ember.svg'); }
.mat-leg    { background-color: #ff8000; -webkit-mask-image: url('../assets/icons/crafting/astral_core.svg');  mask-image: url('../assets/icons/crafting/astral_core.svg'); }

.mat-el-physical  { -webkit-mask-image: url('../assets/icons/crafting/el_physical.svg');  mask-image: url('../assets/icons/crafting/el_physical.svg'); }
.mat-el-fire      { -webkit-mask-image: url('../assets/icons/crafting/el_fire.svg');      mask-image: url('../assets/icons/crafting/el_fire.svg'); }
.mat-el-ice       { -webkit-mask-image: url('../assets/icons/crafting/el_ice.svg');       mask-image: url('../assets/icons/crafting/el_ice.svg'); }
.mat-el-lightning { -webkit-mask-image: url('../assets/icons/crafting/el_lightning.svg'); mask-image: url('../assets/icons/crafting/el_lightning.svg'); }
.mat-el-holy      { -webkit-mask-image: url('../assets/icons/crafting/el_holy.svg');      mask-image: url('../assets/icons/crafting/el_holy.svg'); }
.mat-el-shadow    { -webkit-mask-image: url('../assets/icons/crafting/el_shadow.svg');    mask-image: url('../assets/icons/crafting/el_shadow.svg'); }

.craft-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 12px;
}

.craft-tab {
    flex: 1;
    padding: 8px 0;
    border: 1px solid #2a2520;
    border-radius: 3px;
    background: rgba(20,18,14,0.6);
    color: #5a5040;
    font-family: 'Cinzel', serif;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    text-align: center;
    transition: all 0.12s;
}

.craft-tab:hover { border-color: #4a4030; color: #8a7a5a; }
.craft-tab.active { border-color: #5a4a2a; color: #c4a35a; background: rgba(196,163,90,0.06); }

/* Dismantle tab */
.dism-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.dism-check {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.dism-check input { cursor: pointer; accent-color: #c4a35a; }

.dism-mass {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(20,18,14,0.6);
    border: 1px solid #2a2520;
    border-radius: 3px;
    margin-bottom: 10px;
}

.dism-yield {
    font-size: 12px;
    color: #8a7a5a;
}

.craft-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    max-height: 300px;
}

/* Craft tab */
.craft-section {
    margin-bottom: 12px;
}

.craft-section-title {
    font-family: 'Cinzel', serif;
    font-size: 11px;
    font-weight: 600;
    color: #7a6a4a;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.craft-slot-row, .craft-rar-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.craft-slot-btn {
    flex: 1;
    min-width: 60px;
    padding: 7px 4px;
    border: 1px solid #2a2520;
    border-radius: 3px;
    background: rgba(20,18,14,0.6);
    color: #5a5040;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 0.12s;
}

.craft-slot-btn:hover { border-color: #4a4030; color: #8a7a5a; }
.craft-slot-btn.active { border-color: #5a4a2a; color: #c4a35a; background: rgba(196,163,90,0.06); }

.craft-rar-btn {
    flex: 1;
    padding: 7px 4px;
    border: 1px solid #2a2520;
    border-radius: 3px;
    background: rgba(20,18,14,0.6);
    color: var(--rc, #5a5040);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.12s;
    opacity: 0.6;
}

.craft-rar-btn:hover { border-color: var(--rc); opacity: 0.8; }
.craft-rar-btn.active { border-color: var(--rc); opacity: 1; background: rgba(196,163,90,0.04); }

.craft-mat-sep {
    width: 1px;
    align-self: stretch;
    background: #2a2520;
    margin: 0 2px;
}

.craft-el-row { display: flex; gap: 4px; flex-wrap: wrap; }
.craft-el-btn {
    flex: 1;
    min-width: 58px;
    padding: 6px 4px;
    border: 1px solid #2a2520;
    border-radius: 3px;
    background: rgba(20,18,14,0.6);
    color: var(--ec, #8a7a5a);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.12s;
    opacity: 0.6;
}
.craft-el-btn:hover { border-color: var(--ec, #4a4030); opacity: 0.85; }
.craft-el-btn.active { border-color: var(--ec, #5a4a2a); opacity: 1; background: rgba(196,163,90,0.06); }

.craft-preview {
    padding: 12px;
    background: rgba(20,18,14,0.6);
    border: 1px solid #2a2520;
    border-radius: 3px;
    margin-bottom: 12px;
    text-align: center;
}

.craft-preview-ilvl {
    font-size: 11px;
    color: #5a5040;
    margin-bottom: 4px;
}

.craft-preview-cost {
    font-size: 13px;
    color: #a8a090;
    font-weight: 500;
}

.craft-btn {
    width: 100%;
    padding: 10px;
    font-size: 13px;
}

/* Transform tab */
.transform-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 12px;
    background: rgba(20,18,14,0.6);
    border: 1px solid #2a2520;
    border-radius: 3px;
    margin-bottom: 8px;
}

.transform-slot {
    width: 70px;
    height: 70px;
    border: 2px solid #3a3428;
    border-radius: 4px;
    background: rgba(10,10,14,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.transform-slot-amount {
    font-size: 14px;
    font-weight: 700;
}

.transform-slot-name {
    font-size: 9px;
    color: #6a6050;
    text-align: center;
    line-height: 1.1;
}

.transform-arrow {
    color: #5a5040;
    font-size: 18px;
}

.transform-btn {
    padding: 6px 14px;
    border: 1px solid #3a3428;
    border-radius: 3px;
    background: rgba(60,120,180,0.06);
    color: #6a9aba;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.transform-btn:hover {
    background: rgba(60,120,180,0.15);
    border-color: #4a6a8a;
}

.transform-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.detail-btn {
    flex: 1;
    padding: 8px 0;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.detail-btn-equip {
    border: 1px solid #5a4a2a;
    background: rgba(196,163,90,0.08);
    color: #c4a35a;
}

.detail-btn-equip:hover {
    background: rgba(196,163,90,0.18);
}

.detail-btn-unequip {
    border: 1px solid #4a4030;
    background: rgba(100,90,70,0.06);
    color: #8a7a5a;
}

.detail-btn-unequip:hover {
    background: rgba(100,90,70,0.15);
}

.detail-btn-dismantle {
    border: 1px solid #2a3a4a;
    background: rgba(60,120,180,0.06);
    color: #6a9aba;
}

.detail-btn-dismantle:hover {
    background: rgba(60,120,180,0.15);
}

.detail-btn-sell {
    border: 1px solid #4a3020;
    background: rgba(180,80,40,0.06);
    color: #b86030;
}

.detail-btn-sell:hover {
    background: rgba(180,80,40,0.15);
}

/* =========================================
   STATS MODAL
   ========================================= */

.power-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: rgba(196,163,90,0.04);
    border: 1px solid #3a3428;
    border-radius: 3px;
}

.power-banner-label {
    font-family: 'Cinzel', serif;
    font-size: 12px;
    font-weight: 600;
    color: #7a6a4a;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.power-banner-value {
    font-family: 'Cinzel', serif;
    font-size: 22px;
    font-weight: 700;
    color: #c4a35a;
}

.stats-section {
    margin-bottom: 16px;
}

.stats-section-title {
    font-family: 'Cinzel', serif;
    font-size: 12px;
    font-weight: 600;
    color: #7a6a4a;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(196,163,90,0.12);
}

.stat-row {
    display: grid;
    grid-template-columns: 32px 90px 1fr 50px auto;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.stat-icon {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: rgba(196,163,90,0.08);
    border: 1px solid #2a2520;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.stat-name {
    color: #c4a35a;
    font-weight: 600;
    font-size: 13px;
}

.stat-desc {
    color: #4a4538;
    font-size: 11px;
}

.stat-value {
    color: #e8e0d0;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
}

.stat-buy-btn {
    padding: 5px 0;
    width: 100px;
    border: 1px solid #3a3428;
    border-radius: 3px;
    background: rgba(196, 163, 90, 0.06);
    color: #a89060;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
    text-align: center;
}

.stat-buy-btn:hover {
    background: rgba(196, 163, 90, 0.15);
    border-color: #5a4a2a;
    color: #c4a35a;
}

.stat-buy-btn:disabled {
    border-color: #1e1a14;
    color: #3a3530;
    cursor: not-allowed;
    background: transparent;
}

/* Derived stats grid */
.derived-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 32px;
}

.derived-row {
    display: grid;
    grid-template-columns: 1fr 55px 55px 55px;
    gap: 0 4px;
    padding: 3px 4px;
    margin: 0 -4px;
    font-size: 12px;
    align-items: baseline;
    border-radius: 2px;
    transition: background 0.1s;
}

.derived-row:hover {
    background: rgba(196, 163, 90, 0.06);
}

.derived-row .dr-label {
    color: #6a6050;
}

.derived-row .dr-value {
    color: #a8a090;
    font-weight: 500;
    text-align: right;
}

.derived-row .dr-gear {
    color: #1eff00;
    font-size: 11px;
    font-weight: 400;
    text-align: right;
}

.derived-row .dr-total {
    color: #c4a35a;
    font-size: 11px;
    font-weight: 600;
    text-align: right;
}

.derived-row-simple {
    grid-template-columns: 1fr 55px;
}

.derived-row .dr-total-only {
    color: #a8a090;
    font-weight: 500;
    text-align: right;
    grid-column: 2 / -1;
}

.gold-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    margin-top: 12px;
    background: rgba(196,163,90,0.04);
    border: 1px solid #2a2520;
    border-radius: 3px;
}

.gold-bar .gold-icon {
    width: 16px;
    height: 16px;
    background: radial-gradient(circle at 40% 35%, #ffd700, #b8860b);
    border-radius: 50%;
    border: 1px solid #8b6914;
}

.gold-bar .gold-amount {
    color: #d4a017;
    font-size: 15px;
    font-weight: 600;
}

/* =========================================
   EQUIPMENT MODAL
   ========================================= */

/* Equipment slot grid */
.equip-slots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.equip-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(20,18,14,0.8);
    border: 1px solid #2a2520;
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.15s;
    min-height: 52px;
}

.equip-slot:hover {
    border-color: #4a4030;
}

.equip-slot.has-item {
    border-color: #3a3428;
}

.equip-slot .slot-icon {
    width: 32px;
    height: 32px;
    border-radius: 3px;
    background: rgba(196,163,90,0.04);
    border: 1px solid #2a2520;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #4a4030;
    flex-shrink: 0;
}

.equip-slot .slot-info {
    flex: 1;
    min-width: 0;
}

.equip-slot .slot-label {
    font-size: 10px;
    color: #5a5040;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.equip-slot .slot-item-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.equip-slot .slot-empty {
    font-size: 11px;
    color: #3a3530;
    font-style: italic;
}

/* Skill bar in equipment panel */
.equip-skill-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.equip-skill-slot {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(20,18,14,0.8);
    border: 1px solid #2a2520;
    border-radius: 3px;
    position: relative;
    cursor: default;
    transition: border-color 0.15s;
}

.equip-skill-slot[onclick] {
    cursor: pointer;
}

.equip-skill-slot[onclick]:hover {
    border-color: #4a4030;
}

.equip-skill-key {
    width: 28px;
    height: 28px;
    border: 2px solid #3a3428;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 700;
    color: #c4a35a;
    background: rgba(10,10,14,0.6);
    flex-shrink: 0;
}

.equip-skill-info {
    flex: 1;
    min-width: 0;
}

.equip-skill-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.equip-skill-meta {
    font-size: 10px;
    text-transform: capitalize;
    opacity: 0.6;
}

.skill-bar-arrow {
    color: #5a5040;
    font-size: 10px;
    flex-shrink: 0;
}

/* Skill dropdown */
.skill-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: -1px;
    right: -1px;
    margin-top: 2px;
    background: linear-gradient(180deg, #1a1714, #121010);
    border: 1px solid #4a4030;
    border-radius: 3px;
    z-index: 10;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
    overflow: hidden;
}

.skill-dropdown.open {
    display: block;
}

.dd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.1s;
}

.dd-item:hover {
    background: rgba(196,163,90,0.06);
}

.dd-item-active {
    background: rgba(196,163,90,0.08);
    border-left: 2px solid #c4a35a;
}

.dd-item-slot {
    font-size: 9px;
    color: #5a5040;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 50px;
}

.dd-item-name {
    font-size: 12px;
    font-weight: 600;
    flex: 1;
}

.dd-item-elem {
    font-size: 10px;
    text-transform: capitalize;
}

/* Inventory tabs */
.inv-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 10px;
}

.inv-tab {
    flex: 1;
    padding: 6px 0;
    border: 1px solid #2a2520;
    border-radius: 3px;
    background: rgba(20, 18, 14, 0.6);
    color: #5a5040;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: all 0.12s;
    text-align: center;
}

.inv-tab:hover {
    border-color: #4a4030;
    color: #8a7a5a;
}

.inv-tab.active {
    border-color: #5a4a2a;
    color: #c4a35a;
    background: rgba(196, 163, 90, 0.06);
}

/* Inventory section */
.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.inventory-title {
    font-family: 'Cinzel', serif;
    font-size: 12px;
    font-weight: 600;
    color: #7a6a4a;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
    gap: 8px;
}

.inv-item {
    width: 74px;
    height: 74px;
    border: 1px solid #2e2a20;
    border-radius: 6px;
    background: linear-gradient(180deg, rgba(28,24,18,0.85) 0%, rgba(14,12,9,0.85) 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    position: relative;
}

.inv-item:hover {
    border-color: #7a6a3a;
    box-shadow: 0 0 12px rgba(196,163,90,0.18);
    transform: translateY(-1px);
}

.inv-item.equipped::after {
    content: 'E';
    position: absolute;
    top: 3px;
    right: 4px;
    font-size: 9px;
    font-weight: 800;
    color: #ffe8a8;
    background: rgba(196, 163, 90, 0.85);
    border-radius: 3px;
    padding: 1px 4px;
    line-height: 1;
}

.inventory-count {
    font-family: inherit;
    font-size: 12px;
    color: #8a7a5a;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.inventory-count.full {
    color: #cc6a4a;
}

.inv-item.inv-empty {
    cursor: default;
    opacity: 0.3;
}

.inv-item.inv-empty:hover {
    border-color: #2a2520;
    box-shadow: none;
}

/* Inventory list view (alternative) */
.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(20, 18, 14, 0.8);
    border: 1px solid #2a2520;
    border-left: 3px solid #2a2520;
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.item-card:hover {
    border-color: #4a4030;
    background: rgba(30, 26, 20, 0.8);
}

.item-card.equipped {
    border-left-color: #c4a35a;
    background: rgba(196, 163, 90, 0.04);
}

.item-name {
    font-weight: 600;
    font-size: 13px;
}

.item-skill {
    font-size: 11px;
    color: #6a6050;
    margin-top: 1px;
}

.item-element {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.equip-btn {
    padding: 4px 14px;
    border: 1px solid #3a3428;
    border-radius: 3px;
    background: transparent;
    color: #a89060;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s;
}

.equip-btn:hover {
    background: rgba(196, 163, 90, 0.1);
    border-color: #5a4a2a;
    color: #c4a35a;
}

/* =========================================
   STAGE SELECT MODAL
   ========================================= */

/* --- Stage Select: difficulty tabs + one row per chapter --- */
.stage-diff-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #2a2520;
}

.stage-diff-tab {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #2a2520;
    border-radius: 3px;
    background: rgba(20, 18, 14, 0.7);
    font-family: 'Cinzel', serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
    color: #5a5040;
}
.stage-diff-tab:hover:not(:disabled) { color: #c4a35a; border-color: #5a4a2a; }
.stage-diff-tab.active { color: #e4d8b0; border-color: #7a6a3a; background: rgba(196,163,90,0.1); box-shadow: 0 0 10px rgba(196,163,90,0.12); }
.stage-diff-tab.diff-hard.active      { color: #ff9a5a; border-color: #a05030; background: rgba(255,100,40,0.08); box-shadow: 0 0 10px rgba(255,100,40,0.15); }
.stage-diff-tab.diff-nightmare.active { color: #d88bff; border-color: #7a3a8a; background: rgba(180,80,220,0.1); box-shadow: 0 0 10px rgba(180,80,220,0.18); }
.stage-diff-tab.locked { cursor: not-allowed; opacity: 0.38; }

.stage-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stage-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 4px 2px;
    border-bottom: 1px solid rgba(196,163,90,0.03);
}

.stage-row-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
    flex-shrink: 0;
}

.stage-row-num {
    font-family: 'Cinzel', serif;
    font-size: 11px;
    font-weight: 700;
    color: #8a7850;
    background: rgba(196,163,90,0.06);
    border: 1px solid #2a2520;
    border-radius: 3px;
    padding: 2px 8px;
    min-width: 32px;
    text-align: center;
}
.stage-row-name {
    font-size: 12px;
    font-weight: 500;
    color: #7a7060;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stage-row-cells {
    display: flex;
    gap: 5px;
    flex: 1;
}

.stage-cell {
    flex: 1;
    padding: 7px 0;
    border: 1px solid #2a2520;
    border-radius: 3px;
    background: rgba(20, 18, 14, 0.8);
    color: #6a6050;
    cursor: pointer;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: all 0.12s;
}
.stage-cell:hover:not(:disabled) { border-color: #4a4030; color: #c4a35a; background: rgba(196,163,90,0.04); }

.stage-cell.cleared {
    color: #8ad88a;
    border-color: #3a5a3a;
    background: rgba(60, 120, 60, 0.08);
}
.stage-cell.cleared:hover:not(:disabled) {
    color: #a8e8a8;
    border-color: #5a7a5a;
    background: rgba(60, 120, 60, 0.14);
}

.stage-cell.boss {
    color: #cc6060;
    border-color: #6a3030;
    background: rgba(140, 40, 40, 0.08);
    font-family: 'Cinzel', serif;
    letter-spacing: 1px;
}
.stage-cell.boss:hover:not(:disabled) {
    color: #ff7a7a;
    border-color: #8a3030;
    background: rgba(200, 50, 50, 0.12);
}
.stage-cell.boss.cleared {
    color: #d8a868;
    border-color: #7a5030;
    background: rgba(180, 120, 40, 0.1);
}

.stage-cell.current {
    box-shadow: 0 0 0 2px #c4a35a inset, 0 0 10px rgba(196,163,90,0.25);
    color: #ffe9a8;
}

.stage-cell.locked {
    cursor: not-allowed;
    opacity: 0.28;
    color: #4a4538;
    background: rgba(14, 13, 10, 0.6);
}

/* --- Skills modal --- */
.skills-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 18px 16px;
}
.skills-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid #2a2520;
    padding-bottom: 6px;
    flex-shrink: 0;
}
.skills-tab {
    flex: 1;
    background: rgba(14, 14, 18, 0.5);
    border: 1px solid #2e2a20;
    border-radius: 8px;
    color: #8a7a5a;
    padding: 8px 4px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.skills-tab:hover {
    color: #c4a35a;
    border-color: #4a4030;
}
.skills-tab.active {
    color: #e4d8b0;
    background: rgba(196, 163, 90, 0.15);
    border-color: #7a6a3a;
    box-shadow: 0 0 8px rgba(196,163,90,0.18);
}
.skills-tab-key {
    background: rgba(0,0,0,0.4);
    border: 1px solid currentColor;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 10px;
    line-height: 1;
}

.skills-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    padding: 4px;
    align-content: start;
}

.skill-card {
    position: relative;
    background: rgba(20, 18, 14, 0.7);
    border: 1px solid #2e2a20;
    border-radius: 8px;
    padding: 10px 8px 8px;
    text-align: center;
    cursor: default;
    transition: all 0.15s;
    overflow: hidden;
}
.skill-card.available {
    cursor: pointer;
    background: rgba(28, 24, 18, 0.85);
}
.skill-card.available:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(196,163,90,0.2);
}
.skill-card.active {
    background: rgba(60, 48, 18, 0.7);
    border-color: #c4a35a;
    box-shadow: 0 0 14px rgba(196,163,90,0.35);
}
.skill-card.locked {
    opacity: 0.35;
    filter: grayscale(0.7);
}

.skill-card-slot {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0,0,0,0.55);
    border: 1px solid #4a4030;
    color: #c4a35a;
    font-weight: 800;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.skill-card-tag {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #8a7a5a;
    background: rgba(0,0,0,0.5);
    border: 1px solid #2e2a20;
    border-radius: 4px;
    padding: 1px 5px;
    text-transform: uppercase;
}
.skill-card.active .skill-card-tag {
    color: #ffe8a8;
    border-color: #c4a35a;
    background: rgba(196,163,90,0.18);
}
.skill-card.locked .skill-card-tag {
    color: #6a6050;
}

.skill-card-icon {
    width: 56px;
    height: 56px;
    margin: 14px auto 6px;
    background: linear-gradient(180deg, #1a1813 0%, #08070c 100%);
    border: 1px solid #3a3024;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.skill-card-icon img {
    width: 36px;
    height: 36px;
    filter: brightness(0) invert(1) sepia(1) saturate(2) hue-rotate(-30deg);
}
.skill-card.active .skill-card-icon {
    border-color: #c4a35a;
    box-shadow: 0 0 10px rgba(196,163,90,0.4);
}
.skill-card-name {
    font-size: 12px;
    font-weight: 600;
    margin: 4px 0 2px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.skill-card-meta {
    font-size: 10px;
    text-transform: capitalize;
    opacity: 0.75;
}
