: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 & MOBILE FIRST RESET ===== */
* {
    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;
}

.site-frame {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

/* ========== PANELS (MOBILE) ========== */
.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: auto;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    gap: 10px;
}

.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 */
#ore-list-box {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#rune-list-box-left {
    flex: 1;
    min-height: 250px;
    overflow-y: auto;
    border-bottom: none;
}

/* ========== CALCULATOR CENTER ========== */
.center-inner {
    padding: 10px;
    display: flex;
    flex-direction: column;
}

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

#calculator-box h1 {
    margin: 0;
    padding-bottom: 0;
    border-bottom: none;
    font-size: 20px;
}

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

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

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

/* =========================================
   ORE SLOTS
   ========================================= */
.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(--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;
}


/* =========================================
   RUNE SLOTS
   ========================================= */
#rune-inputs-block {
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

#rune-inputs-block h3 {
    margin: 0 0 12px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
    font-size: 1em;
    text-align: center;
}

.rune-slots {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
}

.rune-slot-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 75px;
}

.rune-slot {
    width: 75px;
    height: 75px;
    flex-shrink: 0;
    background: var(--panel-2);
    border: 2px dashed #888;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.rune-slot.filled {
    border: 2px solid purple;
    background: #000;
    display: block;
}

.rune-slot:hover {
    background: #3a3a3a;
}

.rune-slot-icon-display {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
    opacity: 0.9;
}

.rune-slot.filled .slot-name {
    position: absolute;
    top: 3px;
    left: 4px;
    width: auto;
    font-size: 0.75em;
    font-weight: 700;
    color: var(--white);
    text-align: left;
    line-height: 1.1;
    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;
}

.rune-edit-btn {
    width: 100%;
    padding: 4px;
    font-size: 0.8em;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

.rune-edit-btn:hover {
    background: var(--panel-2);
    color: var(--white);
    border-color: var(--accent);
}

.rune-edit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--border);
}

/* =========================================
   MODAL (POPUP)
   ========================================= */
.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;
}

.rune-input-row:has(.rune-section-label:contains("Main")) {
    display: none !important;
}

.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;
}


/* =========================================
   CONTROLS
   ========================================= */
#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-buttons {
    display: flex;
    width: 100%;
    justify-content: space-around;
    gap: 8px;
}

.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;
}

.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 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    cursor: pointer;
    color: var(--text);
    font-weight: 600;
    transition: .12s;
    font-size: 1em;
}

.seg-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 {
    background: #2a72d0;
}

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

#build-dock {
    margin-top: 10px;
    padding: 10px;
}

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

.dock-slot {
    flex: 1;
    background: var(--panel);
    border: 1px dashed var(--border);
    border-radius: 6px;
    height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.1s;
    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-icon {
    font-size: 1.2em;
    margin-bottom: 2px;
    z-index: 2;
}

.dock-label {
    font-size: 0.7em;
    color: var(--muted);
    z-index: 2;
}

.dock-slot.filled .dock-label {
    color: var(--white);
    font-weight: bold;
    text-shadow: 0 1px 2px black;
}

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

@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);
    }
}

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

#saved-builds-container {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 10px;
    display: flex;
}

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

#saved-builds-container::-webkit-scrollbar {
    height: 8px;
}

#saved-builds-container::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

.saved-build-card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    min-width: 320px;
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 100%;
    overflow-y: auto;
}

.saved-build-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.build-title {
    font-weight: bold;
    color: var(--white);
    font-size: 1.1em;
}

.delete-build-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.2em;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

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

.build-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 8px;
    font-size: 0.9em;
    color: var(--muted);
}

.build-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 6px;
}

.build-item-icon {
    width: 42px;
    height: 42px;
    border: 2px solid var(--border);
    border-radius: 6px;
    background-color: #000;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    position: relative;
}

.build-item-icon .icon-label {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.6em;
    padding: 1px 3px;
    border-top-left-radius: 4px;
}

.build-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.build-item-name {
    font-weight: bold;
    font-size: 0.9em;
    margin-bottom: 2px;
}

.build-item-stats {
    font-size: 0.8em;
    color: var(--muted);
    line-height: 1.2;
}

#autofill-box.autofill-card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-top: 12px;
}

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

#credits-box.credits-card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    margin-top: auto;
}

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

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

#rarity-mult-box.card {
    margin-bottom: 0;
    padding: 10px;
}

#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);
}

.enhancement-block .number-wrapper .num-btn.minus {
    border-radius: 4px;
    margin: 0;
}

.enhancement-block .number-wrapper .num-btn.plus {
    border-radius: 4px;
    margin: 0;
}

/* Results */
.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;
}

.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;
}

.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);
}

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

.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;
}

.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;
}

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

.ore-list-item,
.rune-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));
}

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

.ore-list-item:hover,
.rune-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);
}

.rune-list-item:hover {
    box-shadow: 0 0 10px var(--rune-color);
}

.ore-bg-image,
.rune-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,
.rune-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 {
    bottom: 2px;
    font-size: 0.7em;
}

.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-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 6px;
    gap: 4px;
}

.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);
}

.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;
}

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

.wip-container {
    position: relative !important;
    overflow: hidden;
}

.wip-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: inherit;
    pointer-events: all;
    cursor: not-allowed;
}

.wip-badge {
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--accent);
    color: var(--white);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    transform: rotate(-3deg);
}

.wip-badge.sm {
    font-size: 0.6em;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0;
    transform: rotate(0deg);
    white-space: nowrap;
}

.wip-overlay.allow-click {
    pointer-events: none;
    cursor: pointer;
}

button.wip-container {
    position: relative;
    overflow: hidden;
    vertical-align: middle;
}

/* =========================================
   DESKTOP MEDIA QUERY (Corrected)
   ========================================= */
@media (min-width: 900px) {
    body {
        padding: 20px;
        /* Reduced padding slightly to give more room */
        height: 100vh;
        /* Force body to be full screen height */
        overflow: hidden;
        /* optional: prevents double scrollbars if content fits */
    }

    .site-frame {
        display: grid;
        grid-template-columns: 22% 46% 32%;
        gap: 8px;
        align-items: stretch;
        /* Crucial: Ensures all 3 columns are same height */
        height: 100%;
        /* Fill the available body height */
        min-height: 0;
        /* Important for flex/grid scrolling children */
    }

    /* 1. MASTER: Center Panel Structure */
    #center-panel {
        height: 100%;
        display: flex;
        /* Enable flex to stretch the inner child */
        flex-direction: column;
        min-height: 0;
        /* Allow shrinking */
    }

    /* 2. FORCE STRETCH: Make the gray box fill the column */
    #center-panel .panel-inner {
        flex: 1;
        /* Grow to fill the column height */
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    /* 3. SLAVES: Left and Right panels */
    #left-panel,
    #right-panel {
        height: 100%;
        position: relative;
    }

    /* Ensure internals fill the space */
    .panel-inner.left-panel-flex,
    .panel-inner.results-inner {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100% !important;
        /* Force full height */
        display: flex;
        flex-direction: column;
    }

    /* === LEFT PANEL INTERNALS === */
    .panel-inner.left-panel-flex {
        gap: 15px;
    }

    #ore-list-box,
    #rune-list-box-left {
        flex: 0 0 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /* Explicit Height Locking for Lists (4x4 Grid) */
    #ore-list,
    #rune-list {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        height: auto;
        max-height: 340px;
        overflow-y: auto;
        padding-right: 4px;
        flex-grow: 0;
    }

    /* === RIGHT PANEL INTERNALS (RESULTS) === */
    #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;
    }

    /* The main flex container */
    #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;
    }

    /* Top cards take natural size */
    .comp-card,
    .results-card {
        flex: 0 0 auto;
    }

    /* Odds card fills remaining space */
    .odds-card {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 150px;
    }

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

    /* ONLY THE ODDS CONTENT SCROLLS */
    #odds-area {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        padding-right: 4px;
    }

    /* Restore specific desktop stylings */
    .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;
    }

    .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;
    }

    /* Make sure the calculator box inside center expands too */
    #calculator-box {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

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

    /* Push credits to bottom if we want them anchored */
    #credits-box {
        margin-top: auto;
    }
}