/* --- THEME CONFIG --- */
:root {
    --bg-app: #050505;
    --bg-panel: #0a0a0a;
    --bg-input: #121212;
    --bg-dropdown: #18181b;
    --border: #27272a;

    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;
    --text-dim: #52525b;

    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.15);

    /* Rarities */
    --r-common: #9ca3af;
    --r-uncommon: #34d399;
    --r-rare: #60a5fa;
    --r-epic: #a78bfa;
    --r-legendary: #fbbf24;
    --r-mythic: #f472b6;
    --r-exotic: #ef4444;

    /* Zone Themes */
    --z-fire: #ef4444;
    --z-ice: #06b6d4;
    --z-nature: #22c55e;
    --z-void: #9333ea;
    --z-water: #0ea5e9;
    --z-sand: #eab308;
    --z-cave: #64748b;
}

* {
    box-sizing: border-box;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    overflow: hidden;
}

/* SCROLLBAR */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* --- HEADER & CONTROLS --- */
.top-panel {
    background-color: var(--bg-app);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 50;
    /* Higher z-index for dropdowns */
    display: flex;
    flex-direction: column;
}

.header-row {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.brand {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand svg {
    width: 24px;
    height: 24px;
    fill: var(--accent);
}

.header-actions {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.bmc-button-small {
    background: #FFDD00;
    color: #000;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s;
}

.bmc-button-small:active {
    transform: scale(0.95);
}

.wiki-btn {
    background: var(--bg-dropdown);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.wiki-btn:hover {
    background: var(--bg-panel);
}

/* Timers Row */
.timers-row {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 1.5rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.timer-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 120px;
}

.timer-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timer-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: 700;
}

.active-text {
    color: #4ade80;
    /* Green for active events */
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

/* Responsive Controls Grid */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    padding: 1rem 1.5rem;
    background-color: var(--bg-panel);
}

.controls-columns {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background-color: var(--bg-panel);
    flex-wrap: wrap;
    align-items: flex-end;
}

.control-column {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1 1 100%;
    min-width: 150px;
}

/* Make inputs single row on large screens */
@media (min-width: 1024px) {
    .controls-columns {
        display: flex;
        flex-direction: row !important;
        align-items: flex-end;
        flex-wrap: nowrap;
        gap: 1rem;
        width: 100%;
    }

    .control-column {
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        gap: 1rem;
        flex: 1;
    }

    .control-group {
        flex: 1;
        min-width: 0;
        /* Prevent overflow */
    }
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
}

label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- CUSTOM INPUTS & DROPDOWNS --- */
.custom-input {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    width: 100%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: text;
}

.custom-input:focus,
.custom-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Remove spinners */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

/* Dropdown Container */
.dropdown-wrapper {
    position: relative;
}

/* The Dropdown Menu (Hidden by default) */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background-color: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-top: 4px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: none;
    /* Hidden */
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.1s, transform 0.1s;
}

.dropdown-menu.open {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.dropdown-item {
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
}

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

.dropdown-item:hover,
.dropdown-item.selected {
    background-color: var(--bg-panel);
    color: var(--text-main);
}

/* Item Content Styling */
.color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.item-label {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 700;
    text-transform: uppercase;
}

/* --- MAIN CONTENT (Table) --- */
.main-content {
    flex-grow: 1;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-app);
}

.table-wrapper {
    height: 100%;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

th {
    text-align: left;
    padding: 0.8rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background-color: var(--bg-panel);
    z-index: 10;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

th:hover {
    color: var(--text-main);
    background: var(--bg-hover);
}

th.active-sort {
    color: var(--accent);
}

.th-content {
    display: flex;
    align-items: center;
    gap: 6px;
}

th.text-right .th-content {
    justify-content: flex-end;
}

.sort-icon {
    width: 12px;
    height: 12px;
    opacity: 0.3;
}

th.active-sort .sort-icon {
    opacity: 1;
}

td {
    padding: 0.8rem 1.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.9rem;
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.03);
}

/* Row Styling */
.row-best {
    background: linear-gradient(90deg, rgba(234, 179, 8, 0.1) 0%, transparent 100%);
}

.row-best td:first-child {
    box-shadow: inset 3px 0 0 var(--r-legendary);
}

.best-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: rgba(251, 191, 36, 0.2);
    color: var(--r-legendary);
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 6px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.location-text {
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.row-best .location-text {
    color: var(--text-main);
    font-weight: 700;
}

.mineral-link {
    color: var(--text-main);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
    display: block;
}

.mineral-link:hover {
    color: var(--accent);
}

/* Rarity Styles */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 80px;
    background: rgba(255, 255, 255, 0.05);
}

.type-common {
    color: var(--r-common);
    border: 1px solid rgba(156, 163, 175, 0.3);
}

.type-uncommon {
    color: var(--r-uncommon);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.type-rare {
    color: var(--r-rare);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.type-epic {
    color: var(--r-epic);
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.type-legendary {
    color: var(--r-legendary);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.type-mythic {
    color: var(--r-mythic);
    border: 1px solid rgba(244, 114, 182, 0.3);
}

.type-exotic {
    color: var(--r-exotic);
    border: 1px solid rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
}

/* Text Utils */
.mono-text {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.prob-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.batches-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-main);
}

.batches-sub {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 2px;
}

.percent-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.effort-easy {
    color: var(--r-uncommon);
}

.effort-mid {
    color: var(--accent);
}

.effort-hard {
    color: var(--r-legendary);
}

.effort-insane {
    color: var(--r-exotic);
}

#no-results {
    display: none;
    text-align: center;
    padding: 3rem;
    color: var(--text-dim);
}

#error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-app);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.error-box {
    text-align: center;
    padding: 2rem;
    border: 1px solid var(--r-exotic);
    border-radius: 8px;
    background: var(--bg-panel);
}

.error-box h2 {
    color: var(--r-exotic);
    margin: 0 0 1rem 0;
}

/* Mobile portrait - header stacks */
@media (max-width: 480px) {
    .header-row {
        flex-direction: column;
        gap: 10px;
        padding: 0.8rem;
    }

    .nav-tabs {
        width: 100%;
        justify-content: center;
    }

    .brand {
        font-size: 1rem;
    }

    .controls-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    th,
    td {
        padding: 0.8rem 1rem;
    }
}

/* --- NAV TABS --- */
.nav-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-input);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-tab:hover {
    color: var(--text-main);
}

.nav-tab.active {
    background: var(--bg-panel);
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* --- MUSEUM VIEW --- */
.museum-controls {
    padding: 1rem 1.5rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.museum-summary {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.summary-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.8rem;
}

.summary .rings-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    width: 100%;
}

.equipment-slot {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    flex: 1 1 140px;
    /* Allow flexible width, min 140px for mobile */
    max-width: 100%;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.8rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-item.empty {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.9rem;
}

/* Museum Grid */
.museum-content {
    padding: 1.5rem;
    overflow-y: auto;
    height: 100%;
}

.museum-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.rarity-row {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    flex: 1 1 calc(50% - 1rem);
    /* 2 per row with gap */
    min-width: 300px;
}

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

.rarity-title {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rarity-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.slots-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Slot Styling */
.museum-slot {
    width: 140px;
    min-height: 140px;
    height: auto;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: all 0.2s;
    cursor: pointer;
}

.museum-slot:hover {
    border-color: var(--text-muted);
    transform: translateY(-2px);
}

.museum-slot.locked {
    opacity: 0.6;
    border-style: dashed;
    justify-content: center;
    align-items: center;
}

.museum-slot.locked:hover {
    opacity: 0.8;
    border-color: var(--accent);
}

.slot-header {
    padding: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.slot-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px;
    text-align: center;
    gap: 4px;
}

.slot-add-icon {
    font-size: 2rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.slot-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.slot-lock-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.slot-cost {
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* Filled Slot */
.museum-slot.filled {
    border-color: var(--accent);
    background: linear-gradient(to bottom, var(--bg-input), rgba(59, 130, 246, 0.05));
}

.ore-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.2;
}

.ore-bonus {
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 4px;
}

.modifier-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    background: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-top: 6px;
    color: var(--text-muted);
}

.remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.museum-slot:hover .remove-btn {
    opacity: 1;
}

.remove-btn:hover {
    background: var(--r-exotic);
    color: white;
    border-color: var(--r-exotic);
}

/* Modal/Dropdown for Selection */
.selection-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

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

.modal-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-body {
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.selection-item {
    padding: 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.1s;
}

.selection-item:hover {
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

.selection-item.active {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.selection-group-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

/* Plan Selector */
.plan-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}

.plan-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.plan-btn:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.plan-btn.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    font-weight: 600;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Tablets and smaller */
@media (max-width: 1024px) {
    .museum-slot {
        min-width: 120px;
        min-height: 140px;
    }

    .slots-container {
        gap: 8px;
    }
}

/* Mobile landscape and portrait tablets */
@media (max-width: 768px) {

    /* Museum controls */
    .plan-selector {
        flex-wrap: wrap;
        gap: 8px;
    }

    .plan-btn {
        flex: 1;
        min-width: 80px;
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    /* Museum slots */
    .museum-slot {
        min-width: 100px;
        min-height: 120px;
        font-size: 0.8rem;
    }

    .slots-container {
        gap: 6px;
        justify-content: center;
    }

    .rarity-header {
        font-size: 0.9rem;
        padding: 8px;
    }

    .ore-name {
        font-size: 0.85rem;
    }

    .ore-bonus {
        font-size: 0.75rem;
    }

    /* Modal improvements */
    .modal-content {
        width: 90%;
        max-width: 500px;
        margin: 5% auto;
    }

    .selection-item {
        padding: 12px;
        font-size: 0.9rem;
    }

    /* Summary panel */
    .museum-summary {
        padding: 1rem;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {

    /* Header */
    .header-row {
        flex-direction: column;
        gap: 10px;
        padding: 0.8rem;
    }

    .nav-tabs {
        width: 100%;
        justify-content: center;
    }

    .nav-tab {
        flex: 1;
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    /* Museum controls */
    .plan-selector {
        flex-direction: row;
        width: 100%;
    }

    .plan-btn {
        flex: 1;
        padding: 10px 8px;
        font-size: 0.8rem;
    }

    /* Action buttons */
    #rename-plan-btn,
    #presets-btn,
    #clear-plan-btn {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
    }

    #rename-plan-btn span,
    #presets-btn span,
    #clear-plan-btn span {
        font-size: 0.85rem;
    }

    /* Museum grid */
    #museum-grid {
        gap: 12px;
        padding: 10px;
    }

    .museum-slot {
        min-width: calc(50% - 6px);
        max-width: calc(50% - 6px);
        min-height: 140px;
        font-size: 0.75rem;
    }

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

    .rarity-header {
        font-size: 0.85rem;
        padding: 6px;
        flex-direction: column;
        gap: 4px;
    }

    .rarity-title {
        font-size: 0.9rem;
    }

    .rarity-stats {
        font-size: 0.7rem;
    }

    .ore-name {
        font-size: 0.8rem;
    }

    .ore-bonus {
        font-size: 0.7rem;
    }

    .modifier-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    /* Modal full screen on mobile */
    .selection-modal {
        padding: 0;
    }

    .modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
    }

    .modal-header {
        padding: 1rem;
        border-bottom: 1px solid var(--border);
    }

    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }

    .selection-item {
        padding: 14px;
        font-size: 0.95rem;
        min-height: 48px;
    }

    /* Summary panel */
    .museum-summary {
        padding: 0.8rem;
    }

    .summary-title {
        font-size: 0.9rem;
        margin-bottom: 0.8rem;
    }

    .summary-grid {
        grid-template-columns: 1fr;
        gap: 6px;
        font-size: 0.85rem;
    }

    .stat-item {
        padding: 8px;
    }

    /* Remove button */
    .remove-btn {
        width: 28px;
        height: 28px;
        font-size: 1.2rem;
        top: 4px;
        right: 4px;
    }

    /* Form inputs in modals */
    #rename-input {
        font-size: 16px !important;
        padding: 12px !important;
    }

    /* Buttons in modals */
    .cancel-btn,
    .confirm-btn {
        padding: 12px 20px !important;
        font-size: 0.95rem !important;
        min-height: 44px;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .museum-slot {
        min-width: 100%;
        max-width: 100%;
    }

    .slots-container {
        grid-template-columns: 1fr;
    }

    .plan-selector {
        flex-direction: column;
    }

    .plan-btn {
        width: 100%;
    }
}

/* Landscape orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        margin: 2% auto;
        max-height: 96vh;
    }

    .modal-body {
        max-height: calc(96vh - 80px);
    }
}

/* ========================================
   EQUIPMENT PLANNER STYLES
   ======================================== */

/* Equipment Controls */
.equipment-controls {
    padding: 1rem 1.5rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.equipment-summary {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.equip-plan-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.equip-plan-btn:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.equip-plan-btn.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    font-weight: 600;
}

/* Equipment Content */
.equipment-content {
    padding: 1.5rem;
    overflow-y: auto;
    height: 100%;
}

.equipment-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.slot-group {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.slot-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.slot-group-title {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.slot-group-title::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
}

/* Equipment Slot Card */
.equipment-slot {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    min-height: 120px;
    display: flex;
    flex-direction: column;
}

.equipment-slot:hover {
    border-color: var(--text-muted);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.equipment-slot.filled {
    border-color: var(--accent);
    background: linear-gradient(to bottom, var(--bg-input), rgba(59, 130, 246, 0.05));
}

.equipment-slot .slot-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.equipment-slot .equipment-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.equipment-slot .equipment-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-style: italic;
}

.equipment-slot .equipment-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.stat-badge.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--r-exotic);
    border-color: rgba(239, 68, 68, 0.3);
}

.recipe-display {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.recipe-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.3rem;
}

.min-weight-badge {
    display: inline-flex;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(34, 197, 94, 0.15);
    color: var(--z-nature);
    border: 1px solid rgba(34, 197, 94, 0.3);
    font-size: 0.65rem;
    font-weight: 700;
}

.blueprint-badge {
    display: inline-flex;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(251, 191, 36, 0.15);
    color: var(--r-legendary);
    border: 1px solid rgba(251, 191, 36, 0.3);
    font-size: 0.65rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.cost-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(251, 191, 36, 0.15);
    color: var(--r-legendary);
    border: 1px solid rgba(251, 191, 36, 0.3);
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.cost-badge.candy {
    background: rgba(244, 114, 182, 0.15);
    color: var(--r-mythic);
    border-color: rgba(244, 114, 182, 0.3);
}

.equipment-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--text-dim);
}

.equipment-empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Mobile Responsive for Columns */
@media (max-width: 768px) {
    .controls-columns {
        flex-direction: column;
        gap: 1rem;
    }

    .control-column {
        min-width: 100%;
    }

    .equipment-grid {
        padding: 10px;
    }

    .slot-group {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .controls-columns {
        padding: 1rem;
    }

    .equipment-slot {
        padding: 1rem;
    }

    .equipment-name {
        font-size: 1rem !important;
    }
}

/* Equipment Planner Styles */
.equipment-slots-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.equipment-slot {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    width: 140px;
    min-height: 180px;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    text-align: center;
}

.equipment-slot:hover {
    border-color: var(--accent);
    background: var(--bg-panel);
    transform: translateY(-2px);
}

.equipment-slot.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.equipment-slot.locked {
    opacity: 0.5;
    cursor: not-allowed;
    border-style: dashed;
}

.equipment-slot .remove-btn {
    opacity: 1;
    background-color: var(--r-exotic);
    color: white;
    border-color: var(--r-exotic);
    z-index: 10;
}

.equipment-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: var(--text-muted);
}

.equipment-empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
}

.equipment-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1.2;
    margin-bottom: 6px;
    min-height: 2.4em;
    /* 2 lines */
    display: flex;
    align-items: center;
    justify-content: center;
}

.equipment-slot.filled .equipment-name {
    color: var(--text-main);
}

.equipment-stats {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    margin-bottom: auto;
}

.stat-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-badge.negative {
    color: var(--r-exotic);
    background: rgba(255, 0, 0, 0.1);
}

.cost-badge {
    font-size: 0.75rem;
    color: var(--r-legendary);
    margin-top: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px 8px;
    border-radius: 12px;
    font-family: 'JetBrains Mono', monospace;
}

.cost-badge.candy {
    color: var(--r-mythic);
}

.premium-slot {
    border-color: rgba(255, 170, 0, 0.3);
    background: linear-gradient(to bottom, var(--bg-input), rgba(255, 170, 0, 0.05));
}

/* Stats Grid for Equipment */
.equipment-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
/* --- MOBILE REDESIGN 2.0 --- */
@media (max-width: 768px) {
    /* Layout & Header */
    body {
        height: 100%; /* Allow body to scroll if needed, but we keep flex layout */
        position: fixed; /* Prevent bouncy scroll on iOS if needed */
        width: 100%;
    }

    .top-panel {
        position: relative;
        z-index: 100;
        max-height: 40vh; /* Limit header height */
        overflow-y: auto; /* Allow scrolling within header if it gets too tall */
    }

    .header-row {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .brand {
        justify-content: center;
        font-size: 1.1rem;
    }

    .header-actions {
        justify-content: center;
        width: 100%;
    }

    .nav-tabs {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }
    
    .nav-tab {
        flex: 1;
        text-align: center;
        padding: 10px 4px; /* Touch target */
        font-size: 0.8rem;
    }

    /* Controls Stacking */
    .controls-columns {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }

    .control-column {
        min-width: 0;
        width: 100%;
    }

    /* Timers */
    .timers-row {
        justify-content: space-between; /* Spread timers */
        padding: 8px 12px;
    }
    
    .timer-card {
        min-width: auto;
        flex: 1;
        align-items: center;
    }

    /* Touch Targets */
    button, .btc-button-small, .nav-tab, input, .dropdown-item {
        min-height: 44px; /* Apple Human Interface Guidelines */
    }
    
    /* TABLE TO CARDS TRANSFORMATION */
    table, thead, tbody, th, td, tr {
        display: block;
    }

    /* Hide Headers */
    thead {
        display: none;
    }

    /* Card Style for Rows */
    tr {
        margin: 0 12px 16px 12px;
        background-color: var(--bg-dropdown); /* Slightly lighter than bg-app */
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 12px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }

    /* Best row highlight */
    .row-best {
        border-color: var(--r-legendary);
        background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, var(--bg-dropdown) 100%);
    }

    /* Flex Cell */
    td {
        padding: 10px 0;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        min-height: 40px;
    }

    td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    /* Label via Attribute */
    td::before {
        content: attr(data-label);
        float: left;
        font-weight: 700;
        color: var(--text-muted);
        font-size: 0.8rem;
        text-transform: uppercase;
        margin-right: 12px;
    }
    
    /* Adjust specific cell content */
    .prob-cell {
        align-items: flex-end; /* Keep aligned to right */
    }
    
    /* Location fix */
    .location-text {
        justify-content: flex-end;
    }

    /* Hide table horizontal scroll */
    .table-wrapper {
        overflow-x: hidden;
    }
    
    /* Equipment Grid Mobile */
    .equipment-grid {
        flex-direction: column;
    }
    
    .equip-slots-container {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); /* Smaller slots on mobile */
    }
    
}
