/* =========================================
   CSS VARIABLES
   ========================================= */
:root {
    --bg: #1e1e1e;
    --panel: #2b2b2b;
    --panel-2: #2f2f31;
    --border: #555;
    --muted: #aaaaaa;
    --accent: #3a8bff;
    --text: #e0e0e0;
    --card-shadow: rgba(0, 0, 0, 0.45);
    --white: #ffffff;
}

/* =========================================
   GLOBAL RESET & BASE STYLES
   ========================================= */
* {
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

*::-webkit-scrollbar {
    width: 0;
    height: 0;
}

body {
    font-family: Arial, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 10px;
    min-height: 100vh;
}

/* =========================================
   LAYOUT STRUCTURE
   ========================================= */
.site-frame {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

/* =========================================
   PANELS
   ========================================= */
.panel {
    background: transparent;
    display: flex;
    flex-direction: column;
}

.panel-inner {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 6px 18px var(--card-shadow);
}

.full-height-panel {
    height: auto;
    min-height: 200px;
    overflow-y: auto;
}

/* Left Panel Flex Container */
.panel-inner.left-panel-flex {
    height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    gap: 10px;
    overflow: hidden;
}

.list-box-container {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 6px 18px var(--card-shadow);
    border-bottom: none;
    display: flex;
    flex-direction: column;
}

#ore-list-box {
    flex: 2;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* rune list column removed */

/* Center Panel */
.center-inner {
    padding: 10px;
    display: flex;
    flex-direction: column;
}

#calculator-box {
    border-radius: 8px;
    padding: 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#calculator-stacked-flex {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

#forge-inputs-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* =========================================
   ORE & RUNE LISTS
   ========================================= */
#ore-list {
    margin: 0;
    padding: 10px;
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    grid-auto-rows: max-content;
    gap: 6px;
    min-height: 0;
}

.ore-list-item {
    display: block;
    position: relative;
    background: #000;
    border-width: 2px;
    border-style: solid;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s, border-color 0.2s;
    aspect-ratio: 1 / 1;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.ore-list-item {
    border-color: var(--ore-color, var(--border));
}

.ore-list-item:hover {
    transform: scale(1.05);
    border-color: var(--white);
    z-index: 10;
}
.ore-list-item:hover {
    box-shadow: 0 0 10px var(--ore-color);
}

/* make odds rows non-interactive-looking */
.odds-grid-row {
    cursor: default;
}

.ore-bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
    opacity: 0.9;
}

.ore-name-display {
    position: absolute;
    left: 3px;
    font-weight: 700;
    color: var(--white);
    text-align: left;
    z-index: 2;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 2px 4px #000;
    pointer-events: none;
    max-width: 95%;
    word-wrap: break-word;
    line-height: 1.1;
}

.ore-name-display {
    top: 2px;
    font-size: 0.8em;
}

/* rune name display removed */

.ore-multiplier {
    position: absolute;
    bottom: 2px;
    right: 3px;
    color: var(--white);
    font-weight: 800;
    font-size: 0.75em;
    z-index: 2;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 2px 4px #000;
    pointer-events: none;
}

.ore-list-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99;
    background: #111;
    border: 1px solid var(--accent);
    padding: 8px;
    border-radius: 4px;
    color: var(--white);
    font-size: 0.9em;
    white-space: pre-wrap;
    width: 180px;
    text-align: center;
    pointer-events: none;
    display: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    margin-bottom: 5px;
}

.ore-list-item:hover .ore-list-tooltip {
    display: block;
}

/* =========================================
   ORE SLOTS (INPUT)
   ========================================= */
.ore-slots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
    padding: 0;
    justify-content: center;
}

.ore-slot-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.ore-slot {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--panel-2);
    border: 2px dashed var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    user-select: none;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: auto;
}

.ore-slot.filled {
    border: 2px solid var(--ore-color, var(--accent));
    background: #000;
    display: block;
}

.ore-slot:hover {
    border-color: #888;
}

.ore-slot.filled:hover {
    border-color: var(--white);
}

.ore-slot-bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
    opacity: 0.9;
}

.ore-slot .slot-name {
    z-index: 2;
    pointer-events: none;
}

.ore-slot:not(.filled) .slot-name {
    color: var(--muted);
    font-size: 0.85em;
    font-weight: 600;
}

.ore-slot.filled .slot-name {
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 0.75em;
    font-weight: 700;
    color: var(--white);
    text-align: left;
    line-height: 1.1;
    max-width: 95%;
    word-wrap: break-word;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 2px 4px #000;
}

.ore-slot .slot-count {
    z-index: 2;
    pointer-events: none;
}

.ore-slot:not(.filled) .slot-count {
    display: none;
}

.ore-slot.filled .slot-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.9em;
    font-weight: 800;
    color: var(--white);
    background: transparent;
    padding: 0;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 2px 4px #000;
}

.ore-controls {
    display: none; /* hidden by default, shown when slot is filled */
    justify-content: space-between;
    width: 100%;
    margin-top: 6px;
    gap: 4px;
}

/* show controls only when the preceding ore-slot is filled */
.ore-slot.filled + .ore-controls {
    display: flex;
}

.ore-btn {
    flex: 1;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    padding: 2px 0;
    transition: 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ore-btn:hover {
    border-color: var(--white);
    color: var(--white);
    background: rgba(255, 255, 255, 0.1);
}

.ore-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

/* rune slots removed */

/* =========================================
   CONTROLS & BUTTONS
   ========================================= */
#controls-and-enhancement {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#controls-bottom-row {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    gap: 10px;
}

.action-msg {
    flex: 1;
    color: #ff9900;
    font-size: 0.9em;
    font-weight: 600;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
    padding-right: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

#action-msg {
    min-height: 18px !important;
    margin-bottom: 4px !important;
    font-size: 0.85em;
}

.action-buttons {
    display: flex;
    width: auto;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.action-btn {
    flex: 1;
    margin: 0;
    padding: 8px 14px;
    border-radius: 999px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    transition: .12s;
    min-width: 80px;
}

.action-btn.equip {
    border-color: var(--accent);
    color: var(--accent);
}

.action-btn.equip:hover {
    background: var(--accent);
    color: var(--white);
}

.action-btn.save:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #a855f7;
    color: #a855f7;
}

.action-btn.clear:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #ff4444;
    color: #ff4444;
}

.seg-btn {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    cursor: pointer;
    color: var(--text);
    font-weight: 600;
    transition: .12s;
    font-size: 1em;
    flex: 1;
    text-align: center;
}

.seg-btn.active,
.header-tab-btn.active,
.world-btn.active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
    box-shadow: 0 0 6px rgba(58, 139, 255, 0.4);
}

.seg-btn.active:hover,
.header-tab-btn.active:hover,
.world-btn.active:hover {
    background: #2a72d0;
}

.seg-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.05);
}

/* =========================================
   ENHANCEMENT & QUALITY INPUTS
   ========================================= */
#rarity-mult-box.card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
}

.full-width-mt {
    width: 100%;
    margin-top: 4px;
    border-radius: 6px;
    padding: 6px;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

#rarity-quality-split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

#rarity-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#rarity-value {
    font-size: 1.5em;
    font-weight: bold;
    text-align: left;
}

#combined-multiplier {
    font-size: 1em;
    color: var(--muted);
}

#quality-input-group {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

#quality-input-group .enh-label {
    display: none;
}

#quality-input-group .input-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px 4px 12px;
    width: 100%;
    height: 42px;
    transition: border-color 0.2s;
    position: relative;
}

#quality-input-group .input-wrapper:focus-within {
    border-color: var(--accent);
}

#quality-input-group .input-wrapper::before {
    content: "Quality";
    color: var(--muted);
    font-size: 1em;
    font-weight: 600;
    margin-right: 5px;
    white-space: nowrap;
}

#quality-input-group .input-wrapper input#quality-amt {
    background: transparent;
    border: none;
    color: var(--text);
    text-align: right;
    font-size: 1.1em;
    width: 100%;
    padding: 0;
    outline: none;
    font-weight: 600;
}

#quality-input-group .input-wrapper span {
    color: var(--muted);
    font-size: 1.1em;
    padding-left: 2px;
    user-select: none;
}

#enhancement-input-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.enhancement-block .enh-label {
    flex-grow: 1;
    background: transparent;
    border: none;
    padding: 0;
    font-weight: 600;
    font-size: 1em;
}

.enhancement-block .number-wrapper {
    display: flex;
    align-items: center;
}

#enhAmt {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    text-align: center;
    font-size: 1.1em;
    width: 60px;
    border-radius: 6px;
    margin: 0 4px;
    padding: 6px 4px;
}

.enhancement-block .number-wrapper .num-btn {
    background: transparent;
    color: var(--white);
    border: 1px solid var(--border);
    box-shadow: none;
    font-weight: normal;
    font-size: 1.5em;
    padding: 2px 10px;
    border-radius: 4px;
    transition: background 0.1s;
}

.enhancement-block .number-wrapper .num-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--white);
}

/* =========================================
   DOCK (LOADOUT)
   ========================================= */
#build-dock {
    margin-top: 0;
    padding: 10px;
}

#build-dock .card-header {
    font-size: 1rem;
    margin-bottom: 8px;
    padding-bottom: 4px;
}

.dock-slots {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 6px;
}

.dock-slot {
    flex: 1;
    background: var(--panel);
    border: 1px dashed var(--border);
    border-radius: 4px;
    height: 45px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.dock-slot:hover {
    border-color: var(--white);
    background: rgba(255, 255, 255, 0.05);
}

.dock-slot.filled {
    border: 1px solid var(--accent);
    background: #000;
}

.dock-label {
    font-size: 0.75em;
    color: var(--muted);
    z-index: 2;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    pointer-events: none;
    text-align: center;
}

.dock-slot.filled .dock-label {
    color: var(--white);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.dock-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.5;
    background-size: cover;
    background-position: center;
}

.dock-actions {
    display: flex;
    gap: 8px;
    margin-top: 0;
}

.dock-actions .action-btn {
    flex: 1;
    padding: 8px 10px;
    font-size: 0.95rem;
    border-radius: 6px;
}

.dock-slot.selectable {
    animation: equipPulse 1.5s infinite;
    cursor: pointer;
}

@keyframes equipPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(58, 139, 255, 0.4);
        border-color: var(--accent);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(58, 139, 255, 0);
        border-color: var(--accent);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(58, 139, 255, 0);
        border-color: var(--accent);
    }
}

/* =========================================
   AUTOFILL & CREDITS
   ========================================= */
#autofill-box.autofill-card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-top: 0;
}

#autofill-box p {
    margin: 0;
    font-size: 0.9em;
    color: var(--muted);
}

#credits-box.credits-card {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 12px;
    margin-top: auto;
    flex-shrink: 0;
}

#credits-box p {
    margin: 0;
    font-size: 0.75em;
    color: var(--text);
    text-align: left;
    line-height: 1.2;
}

#credits-box strong {
    color: var(--muted);
}

#credits-box .header-tab-btn {
    width: auto;
    padding: 4px 10px;
    font-size: 0.75em;
    margin-top: 0 !important;
    margin-left: 10px;
    white-space: nowrap;
}

/* =========================================
   RESULTS PANEL
   ========================================= */
.results-inner {
    height: auto !important;
    margin-top: 0;
    padding: 14px;
    border-radius: 8px;
}

#results-main-header {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 15px;
    padding-bottom: 10px;
    gap: 10px;
}

.header-text-col {
    text-align: center;
    flex: 1;
}

.header-tab-btn {
    width: 100%;
    font-size: 1em;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    white-space: nowrap;
}

.header-tab-btn:hover {
    border-color: var(--white);
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
}

#results-main-header h2 {
    margin: 0 0 5px 0;
    color: var(--text);
    font-size: 1.2em;
}

#results-main-header #empty-message {
    margin: 0;
    font-size: 0.9em;
    color: var(--muted);
    font-style: italic;
}

#results-split-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    overflow: hidden;
}

.card {
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid #3c3c3e;
    border-radius: 8px;
    padding: 10px;
}

.card-header {
    color: var(--muted);
    font-size: 13px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
}

.card-body {
    color: var(--text);
}

.traits-none {
    color: var(--muted);
    font-style: italic;
    font-size: 0.9em;
    padding: 4px 0;
}

.inner-result-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px;
}

.inner-result-header {
    font-size: 0.85em;
    font-weight: bold;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inner-dark-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
}

/* =========================================
   ODDS DISPLAY
   ========================================= */
.odds-card .odds-type-card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    padding: 8px;
}

.odds-card .odds-type-header {
    position: static;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.odds-card .odds-name {
    font-size: 1em;
    font-weight: bold;
}

.odds-card .odds-pct {
    font-size: 1em;
    color: var(--accent);
    font-weight: bold;
    position: static;
}

.odds-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 1.0em;
    color: var(--text);
}

.odds-card li.odds-grid-row {
    display: grid;
    grid-template-columns: 1fr 50px 100px;
    gap: 8px;
    align-items: center;
    padding: 4px 0;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    border: 1px solid transparent;
    border-radius: 4px;
    margin-bottom: 2px;
}

.odds-card li:last-child {
    border-bottom: none;
}

.odds-card li.odds-grid-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.odds-card li.odds-grid-row.selected {
    background: var(--accent) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    box-shadow: 0 0 10px rgba(58, 139, 255, 0.4);
}

.odds-card li.odds-grid-row.selected span {
    color: var(--white) !important;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.col-name {
    text-align: left;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.0em;
}

.col-chance {
    text-align: right;
    color: var(--muted);
    font-family: monospace;
    font-size: 1.1em;
}

.col-val,
.col-dmg,
.col-armor,
.col-dps {
    text-align: right;
    color: var(--muted);
    white-space: nowrap;
    font-size: 1.0em;
}

.col-empty {
    display: none !important;
}

/* =========================================
   FILTERS & SEARCH
   ========================================= */
.ore-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0px 10px 0px;
}

#ore-search {
    background: #2b2b2b;
    border: 1px solid #555;
    color: var(--text);
    padding: 4px 8px;
    border-radius: 6px;
    width: 50%;
}

#ore-search::placeholder {
    color: #888;
}

.world-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px 10px 4px;
    margin-bottom: 0;
}

.world-tag {
    font-size: 0.75em;
    padding: 4px 10px;
    border-radius: 99px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    font-weight: 600;
}

.world-tag:hover {
    border-color: var(--white);
    color: var(--text);
}

.world-tag.active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
    box-shadow: 0 0 5px rgba(58, 139, 255, 0.4);
}

/* =========================================
   MODALS
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.2s ease-out;
}

.modal-content.large-modal {
    width: 95vw;
    max-width: 95vw;
    min-width: 300px;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-content.large-modal .modal-body {
    flex: 1;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.modal-header h3 {
    margin: 0;
    color: var(--accent);
}

#modal-close-btn,
.modal-close-simple {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.5em;
    cursor: pointer;
}

#modal-close-btn:hover,
.modal-close-simple:hover {
    color: var(--white);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-footer {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

#modal-done-btn {
    background: var(--accent);
    color: var(--white);
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

#modal-done-btn:hover {
    background: #2a72d0;
}

.hidden-header {
    display: none !important;
}

/* =========================================
   RUNE MODAL INPUTS
   ========================================= */
.rune-description-input-container {
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    line-height: 1.5;
    font-size: 1em;
    color: var(--text);
}

.rune-description-input-container span {
    white-space: pre-wrap;
}

.inline-input-wrapper {
    display: inline-flex;
    align-items: center;
    background: #1e1e1e;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 4px;
    margin: 0 4px;
    vertical-align: middle;
    height: 30px;
    transition: border-color 0.2s;
}

.inline-input-wrapper:focus-within {
    border-color: var(--accent);
}

input.rune-stat-input.inline {
    width: 55px;
    padding: 4px 2px;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 1em;
    outline: none;
    color: var(--white);
}

.unit-label.inline-unit {
    color: var(--muted);
    font-size: 0.9em;
    padding-left: 2px;
}

.rune-section-label {
    min-width: 50px;
    font-weight: bold;
    color: var(--white);
    font-size: 0.9em;
}

.rune-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.rune-input-param-label {
    font-size: 0.75em;
    color: var(--muted);
    margin-bottom: 4px;
}

.rune-stat-input,
.rune-sub-select {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: #1e1e1e;
    color: var(--white);
    font-size: 1em;
}

.rune-stat-input:focus,
.rune-sub-select:focus {
    border-color: var(--accent);
    outline: none;
}

.input-with-unit {
    display: flex;
    align-items: center;
    background: #1e1e1e;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 8px;
    width: 100%;
    transition: border-color 0.2s;
}

.input-with-unit:focus-within {
    border-color: var(--accent);
}

.input-with-unit input.rune-stat-input {
    border: none;
    background: transparent;
    padding: 8px 2px 8px 0;
    text-align: right;
    width: 100%;
    flex: 1;
    outline: none;
}

.input-with-unit .unit-label {
    color: var(--muted);
    font-size: 0.9em;
    white-space: nowrap;
    padding-left: 2px;
    user-select: none;
}

/* =========================================
   SAVED BUILDS (ADVANCED STATS)
   ========================================= */
.adv-stats-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    overflow: hidden;
    width: 100%;
    padding-bottom: 0;
}

.builds-column {
    order: 2;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-right: 2px;
    width: 100%;
}

.totals-column {
    order: -1;
    flex: 0 0 auto;
    width: 100%;
    max-height: 40vh;
    overflow-y: auto;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#saved-builds-container {
    flex: 1;
    overflow-x: hidden;
    overflow-y: hidden;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

#saved-builds-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.build-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.build-card-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.build-header-title {
    font-weight: bold;
    color: var(--accent);
    font-size: 0.95em;
}

.build-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.edit-build-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.8em;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    font-weight: 600;
}

.edit-build-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(58, 139, 255, 0.1);
}

.delete-build-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.1em;
    cursor: pointer;
    transition: color 0.2s;
}

.delete-build-btn:hover {
    color: #ff4444;
}

.build-items-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    background: var(--panel-2);
    border-bottom: 1px solid var(--border);
}

.build-item-cell {
    background: var(--bg);
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    position: relative;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    min-height: 120px;
}

.build-item-cell:nth-child(2n) {
    border-right: none;
}

.build-item-cell:nth-last-child(-n+2) {
    border-bottom: none;
}

.build-item-icon {
    width: 42px;
    height: 42px;
    margin: 0 auto 4px auto;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: 1px solid transparent;
}

.build-svg-icon {
    width: 24px;
    height: 24px;
    fill: var(--muted);
    opacity: 0.5;
}

.build-item-cell.active .build-svg-icon {
    fill: var(--white);
    opacity: 1;
}

.build-item-name {
    font-size: 0.8em;
    font-weight: bold;
    color: var(--white);
    line-height: 1.2;
    height: 2.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    word-wrap: break-word;
}

.build-item-stats {
    font-size: 0.75em;
    color: var(--muted);
}

.cell-traits {
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    font-size: 0.7em;
    color: var(--muted);
    width: 100%;
    line-height: 1.3;
    white-space: normal;
    word-wrap: break-word;
    text-align: center;
}

.cell-traits div {
    margin-bottom: 4px;
}

.empty-build-msg {
    text-align: center;
    padding: 40px;
    color: var(--muted);
}

/* Sidebar Stats */
.sidebar-header {
    font-size: 1em;
    font-weight: bold;
    color: var(--white);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    flex-shrink: 0;
}

.sidebar-main-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.sidebar-stat-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.sb-stat-val {
    font-size: 1.1em;
    font-weight: bold;
    line-height: 1.2;
}

.sb-stat-label {
    font-size: 0.7em;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.stat-list-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 15px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    padding: 4px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.stat-label {
    color: var(--muted);
}

.stat-val {
    color: var(--accent);
    font-weight: bold;
}

.build-filter-btn {
    font-size: 0.9em;
    padding: 6px 14px;
    border-radius: 99px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}

.build-filter-btn:hover {
    border-color: var(--white);
    color: var(--text);
}

.build-filter-btn.active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
    box-shadow: 0 0 5px rgba(58, 139, 255, 0.4);
}

.build-filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

/* =========================================
   DEV LOG
   ========================================= */
.dev-log-container {
    max-height: 400px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.dev-msg-item {
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    line-height: 1.4;
    font-family: "Consolas", "Monaco", monospace;
    font-size: 0.9em;
    color: var(--muted);
    text-align: left;
}

.dev-msg-item:last-child {
    border-bottom: none;
}

.dev-msg-date {
    color: var(--accent);
    font-weight: bold;
    display: inline-block;
    min-width: 80px;
}

/* =========================================
   DESKTOP RESPONSIVE (min-width: 900px)
   ========================================= */
@media (min-width: 900px) {
    body {
        padding: 20px;
        height: 100vh;
        overflow: hidden;
    }

    .site-frame {
        display: grid;
        grid-template-columns: 22% 46% 32%;
        gap: 8px;
        align-items: stretch;
        height: 100%;
        min-height: 0;
    }

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

    #center-panel .panel-inner {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    #left-panel,
    #right-panel {
        height: 100%;
        position: relative;
    }

    .panel-inner.left-panel-flex,
    .panel-inner.results-inner {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100% !important;
        display: flex;
        flex-direction: column;
    }

    .panel-inner.left-panel-flex {
        gap: 15px;
        overflow: hidden;
    }

    #ore-list-box,
    #rune-list-box-left {
        flex-direction: column;
    }

    #ore-list,
    #rune-list {
        max-height: none !important;
        height: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        overflow-y: auto;
        padding-right: 4px;
        flex-grow: 1;
    }

    #results-main-header {
        flex: 0 0 auto;
        flex-direction: row;
        gap: 0;
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    #results-main-header h2 {
        font-size: 1.4em;
    }

    .header-tab-btn {
        width: auto;
    }

    #results-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
    }

    #results-split-box {
        display: flex;
        flex-direction: column;
        gap: 12px;
        height: 100%;
        overflow: hidden;
    }

    .comp-card,
    .results-card {
        flex: 0 0 auto;
    }

    .odds-card {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 150px;
    }

    .odds-card .card-header {
        flex: 0 0 auto;
    }

    #odds-area {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        padding-right: 4px;
    }

    .rune-slots {
        gap: 20px;
        flex-wrap: nowrap;
    }

    .rune-slot-wrapper {
        width: 85px;
    }

    .rune-slot {
        width: 85px;
        height: 85px;
    }

    .ore-slots {
        grid-template-columns: repeat(4, 85px);
        gap: 12px;
    }

    #controls-bottom-row {
        flex-direction: row;
        width: 100%;
    }

    #trait-selector {
        display: flex;
        width: 100%;
        gap: 10px;
    }

    .seg-btn {
        flex: 1;
        text-align: center;
        border-radius: 6px;
        padding: 10px;
    }

    .action-buttons {
        width: auto;
        flex: 0;
        gap: 8px;
    }

    #quality-input-group .input-wrapper {
        width: 220px;
    }

    .odds-card li.odds-grid-row {
        grid-template-columns: 1fr 60px 100px 90px;
        font-size: 0.95em;
    }

    .col-name,
    .col-dmg,
    .col-armor,
    .col-dps {
        font-size: 0.95em;
    }

    .col-empty {
        display: block !important;
    }

    #calculator-box {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    #calculator-stacked-flex {
        flex: 1;
    }

    #credits-box {
        margin-top: auto;
    }

    .credits-card .credits-inner {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 8px 10px;
        width: 100%;
    }

    .credits-card .credits-dev {
        margin: 0;
        font-size: 1.2em;
        color: var(--muted);
        text-align: left;
        flex: 1;
        font-weight: 800;
    }

    .credits-card .credits-dev strong {
        color: var(--white);
        font-weight: 900;
        font-size: 1.25em;
        line-height: 1;
    }

    .discord-btn {
        display: inline-block;
        padding: 6px 10px;
        background: linear-gradient(180deg, #5865f2, #4752c4);
        color: white;
        text-decoration: none;
        border-radius: 6px;
        border: 1px solid rgba(0,0,0,0.2);
        font-weight: 700;
        font-size: 0.85em;
        box-shadow: 0 4px 12px rgba(67, 56, 202, 0.18);
    }

    .discord-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 8px 20px rgba(67, 56, 202, 0.25);
    }

    body.equip-mode-active .dock-slot {
        transition: all 0.2s;
    }

    body.equip-mode-active .dock-slot.selectable {
        cursor: pointer;
        border-color: var(--accent);
        box-shadow: 0 0 10px rgba(58, 139, 255, 0.5);
    }

    /* Advanced Stats Desktop Layout */
    .adv-stats-layout {
        flex-direction: row;
        overflow: hidden;
        padding-bottom: 0;
    }

    .builds-column {
        flex: 3;
        order: 1;
        overflow-y: auto;
        padding-right: 8px;
    }

    .totals-column {
        flex: 1;
        order: 2;
        min-width: 280px;
        max-width: 350px;
        height: 100%;
        max-height: none;
        overflow-y: auto;
    }

    .stat-list-container {
        display: block;
    }

    .sidebar-main-stats {
        grid-template-columns: 1fr 1fr;
    }

    .build-items-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .build-item-cell {
        border-bottom: none;
        border-right: 1px solid var(--border);
        padding: 12px 10px;
    }

    .build-item-cell:last-child {
        border-right: none;
    }

    .build-item-icon {
        width: 48px;
        height: 48px;
    }

    .build-item-name {
        font-size: 0.95em;
    }

    .build-item-stats {
        font-size: 0.85em;
    }

    .cell-traits {
        font-size: 0.85em;
        text-align: left;
        margin-top: 10px;
        padding-top: 10px;
    }

    .cell-traits div {
        margin-bottom: 6px;
    }
}