/* ── Game Menu Overlay ── */

/* Backdrop dims the game */
.game-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 8999;
    background: rgba(0, 0, 0, 0.5);
    display: none;
}
.game-menu-backdrop.open {
    display: block;
}

/* Menu window: fixed reference size, centered and scaled */
.game-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 1100px;
    height: 650px;
    transform: translate(-50%, -50%) scale(var(--menu-scale, 1));
    transform-origin: center center;
    z-index: 9000;
    display: none;
    background: rgba(12, 12, 22, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(218, 165, 32, 0.25);
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}
.game-menu.open {
    display: flex;
}

/* Thin custom scrollbars for all game menu content */
.game-menu *::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
.game-menu *::-webkit-scrollbar-track {
    background: transparent;
}
.game-menu *::-webkit-scrollbar-thumb {
    background: rgba(218, 165, 32, 0.25);
    border-radius: 2px;
}
.game-menu *::-webkit-scrollbar-thumb:hover {
    background: rgba(218, 165, 32, 0.45);
}
.game-menu * {
    scrollbar-width: thin;
    scrollbar-color: rgba(218, 165, 32, 0.25) transparent;
}

.game-menu-close {
    position: absolute;
    top: 4px;
    right: 6px;
    z-index: 20;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    transition: color 0.15s;
    order: 99;
}
.game-menu-close:hover {
    color: var(--text-primary);
}

/* ── Left sidebar tabs ── */
.game-menu-sidebar {
    width: 64px;
    background: rgba(10, 10, 20, 0.9);
    border-right: 1px solid rgba(218, 165, 32, 0.2);
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    gap: 2px;
    flex-shrink: 0;
}

.game-menu-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}
.game-menu-tab:hover {
    background: rgba(218, 165, 32, 0.08);
}
.game-menu-tab.active {
    background: rgba(218, 165, 32, 0.12);
    border-left-color: var(--text-title);
}
.gm-tab-icon {
    font-size: 20px;
    line-height: 1;
    margin-bottom: 3px;
    font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
}
.game-menu-tab.active .gm-tab-icon {
    filter: drop-shadow(0 0 4px rgba(218, 165, 32, 0.5));
}
.gm-tab-label {
    font-size: 9px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.game-menu-tab.active .gm-tab-label {
    color: var(--text-title);
}

/* ── Main body (two columns) ── */
.game-menu-body {
    flex: 1;
    display: flex;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    padding: 30px 20px 20px;
    gap: 16px;
    overflow: hidden;
}

.game-menu-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.game-menu-detail {
    width: 280px;
    flex-shrink: 0;
    background: rgba(10, 10, 20, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 40px 16px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ── Tab content containers ── */
.gm-tab-content {
    display: none;
    width: 100%;
    height: 100%;
}
.gm-tab-content.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* ── Tab header ── */
.gm-tab-header {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-title);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(218, 165, 32, 0.2);
}

/* ── Detail panel sections ── */
.gm-detail-content {
    display: none;
}
.gm-detail-content.active {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.gm-detail-empty {
    color: var(--text-dim);
    font-size: 12px;
    font-style: italic;
    text-align: center;
    margin-top: 40px;
}

.gm-detail-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-title);
    margin-bottom: 8px;
}
.gm-detail-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
    min-height: 54px;
    max-height: 54px;
    overflow: hidden;
}
.gm-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 3px 0;
}
.gm-detail-row .label {
    color: var(--text-dim);
}
.gm-detail-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 8px 0;
}
.gm-detail-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 12px;
}
.gm-detail-btn {
    width: 100%;
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid rgba(218, 165, 32, 0.3);
    background: rgba(218, 165, 32, 0.08);
    color: var(--text-title);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background 0.15s;
}
.gm-detail-btn:hover {
    background: rgba(218, 165, 32, 0.18);
}
.gm-detail-btn.danger {
    border-color: rgba(231, 76, 60, 0.3);
    background: rgba(231, 76, 60, 0.08);
    color: #e74c3c;
}
.gm-detail-btn.danger:hover {
    background: rgba(231, 76, 60, 0.18);
}

/* ── Equipment tab: character silhouette ── */
.equip-body {
    position: relative;
    width: 300px;
    height: 530px;
    margin: 0 auto;
    background: url('../assets/img/body_silhouette.svg') no-repeat center top;
    background-size: auto 100%;
}

.equip-body .equip-slot {
    position: absolute;
}
.equip-body .equip-slot[data-slot="head"]     { top: 2px;    left: 114px; }
.equip-body .equip-slot[data-slot="body"]     { top: 127px;  left: 111px; }
.equip-body .equip-slot[data-slot="pants"]    { top: 293px;  left: 112px; }
.equip-body .equip-slot[data-slot="hands"]    { top: 256px;  left: 15px; }
.equip-body .equip-slot[data-slot="feet"]     { top: 461px;  left: 115px; }
.equip-body .equip-slot[data-slot="backpack"] { top: 76px;   left: 253px; }

/* ── Equipment tab: toolbelt section ── */
.equip-toolbelt-section {
    margin-top: 16px;
}
.equip-toolbelt-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

/* ── Inventory tab in game menu ── */
.gm-inventory-grid {
    display: grid;
    grid-template-columns: repeat(8, var(--slot-size));
    gap: 6px;
}
.gm-inventory-weight {
    text-align: right;
    font-size: 12px;
    padding: 8px 0;
    letter-spacing: 0.5px;
}

/* ── Skills tab ── */
.gm-skills-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.gm-skill-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 10px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
    position: relative;
}
.gm-skill-row:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}
.gm-skill-row.selected {
    background: rgba(218, 165, 32, 0.08);
    border-color: rgba(218, 165, 32, 0.3);
}
.gm-skill-icon {
    font-size: 26px;
    margin-bottom: 4px;
    font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
}
.gm-skill-info {
    width: 100%;
}
.gm-skill-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.gm-skill-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
.gm-skill-level {
    font-size: 11px;
    color: var(--text-title);
    font-weight: 700;
}
.gm-skill-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}
.gm-skill-bar-fill {
    height: 100%;
    background: var(--text-title);
    border-radius: 2px;
    transition: width 0.3s;
}
.gm-skill-points {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(232, 162, 58, 0.25);
    color: var(--text-title);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

/* Back button */
.gm-back-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 12px;
    transition: background 0.15s, color 0.15s;
}
.gm-back-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.gm-tree-points {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-title);
    background: rgba(232, 162, 58, 0.15);
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 600;
}

/* Skill tree container */
.gm-tree-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}
.gm-tree-overlay-points {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    background: rgba(10, 10, 20, 0.85);
    border: 1px solid rgba(218, 165, 32, 0.3);
    border-radius: 16px;
    padding: 4px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-title);
    pointer-events: none;
    white-space: nowrap;
}
.gm-tree-viewport {
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
    position: relative;
}
.gm-tree-inner {
    transform-origin: 0 0;
    transition: none;
    position: absolute;
    left: 0;
    top: 0;
}
.gm-tree-inner svg {
    display: block;
    overflow: visible;
}
.gm-tree-inner svg .st-node {
    cursor: pointer;
}

/* ── Social tab ── */
.gm-social-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}
.gm-social-tab {
    flex: 1;
    padding: 6px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.gm-social-tab:hover {
    background: rgba(255, 255, 255, 0.04);
}
.gm-social-tab.active {
    background: rgba(218, 165, 32, 0.1);
    border-color: rgba(218, 165, 32, 0.3);
    color: var(--text-title);
}
.gm-player-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gm-player-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}
.gm-player-row:hover {
    background: rgba(255, 255, 255, 0.04);
}
.gm-player-row.selected {
    background: rgba(218, 165, 32, 0.08);
    border-color: rgba(218, 165, 32, 0.2);
}
.gm-player-row.is-friend {
    border-left: 2px solid #2ecc71;
}
.gm-player-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.gm-player-dot.online { background: #2ecc71; }
.gm-player-dot.offline { background: #666; }
.gm-player-name {
    flex: 1;
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}
.gm-player-name.is-friend {
    color: #2ecc71;
}
.gm-player-meta {
    font-size: 10px;
    color: var(--text-dim);
}
.gm-player-ping {
    font-size: 10px;
    color: var(--text-dim);
    min-width: 35px;
    text-align: right;
}
.gm-social-empty {
    color: var(--text-dim);
    font-size: 12px;
    text-align: center;
    margin-top: 20px;
    font-style: italic;
}

/* ── Settings sliders ── */
.game-menu input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.game-menu input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-title);
    border: 2px solid rgba(10, 10, 20, 0.8);
    cursor: pointer;
    margin-top: -5px;
}
.game-menu input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-title);
    border: 2px solid rgba(10, 10, 20, 0.8);
    cursor: pointer;
}
.game-menu input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
}
.game-menu input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
}
.game-menu select {
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    outline: none;
}
.game-menu select:focus {
    border-color: var(--text-title);
}

/* ── Station Crafting Window ── */
.sc-backdrop {
    position: fixed;
    inset: 0;
    z-index: 8999;
    background: rgba(0, 0, 0, 0.5);
    display: none;
}
.sc-backdrop.open { display: block; }

.sc-window {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 900px;
    height: 650px;
    transform: translate(-50%, -50%) scale(var(--menu-scale, 1));
    transform-origin: center center;
    z-index: 9000;
    display: none;
    background: rgba(12, 12, 22, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(218, 165, 32, 0.25);
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}
.sc-window.open { display: flex; flex-direction: column; }

.trade-ship-window { width: 400px; height: auto; max-height: 500px; }
.trade-ship-content { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.trade-ship-timer { font-size: 20px; font-weight: 700; color: var(--text-title); text-align: center; letter-spacing: 2px; }
.trade-ship-completed { text-align: center; font-size: 16px; font-weight: 600; color: #2ecc71; padding: 20px 0; }
.trade-ship-item-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.trade-ship-icon { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; }
.trade-ship-item-info { flex: 1; }
.trade-ship-item-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.trade-ship-item-progress { font-size: 12px; color: var(--text-secondary); }

.sc-tabs {
    display: flex;
    gap: 0;
    padding: 8px 20px 0;
    border-bottom: 1px solid rgba(218, 165, 32, 0.15);
}
.sc-tab-btn {
    padding: 6px 18px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.15s, border-color 0.15s;
}
.sc-tab-btn:hover { color: var(--text-secondary); }
.sc-tab-btn.active {
    color: var(--text-title);
    border-bottom-color: var(--text-title);
}
.sc-tab-crafting, .sc-tab-upgrade { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.sc-tab-upgrade .sc-body { flex-direction: column; }
.sc-upgrade-content { flex: 1; overflow-y: auto; padding: 0 20px; }

.sc-upgrade-info { margin-bottom: 12px; }
.sc-upgrade-title { font-size: 15px; font-weight: 700; color: var(--text-title); margin-bottom: 4px; }
.sc-upgrade-bonus { font-size: 12px; color: #e8a23a; }

.sc-body {
    flex: 1;
    display: flex;
    padding: 30px 20px 20px;
    gap: 16px;
    min-height: 0;
    overflow: hidden;
}
.sc-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.sc-header {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-title);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(218, 165, 32, 0.2);
}
.sc-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.sc-filter-row .sc-filter {
    flex: 1;
    margin-bottom: 0 !important;
}
.sc-show-all {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font-main);
}
.sc-show-all input {
    cursor: pointer;
}
.sc-recipe-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--slot-size), 1fr));
    gap: 6px;
    align-content: start;
}
.sc-recipe-list .gm-build-slot-img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    image-rendering: pixelated;
}
.sc-detail {
    width: 260px;
    flex-shrink: 0;
    background: rgba(10, 10, 20, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.sc-close {
    position: absolute;
    top: 4px;
    right: 6px;
    z-index: 20;
}

/* Scrollbars for station crafting */
.sc-window *::-webkit-scrollbar { width: 4px; height: 4px; }
.sc-window *::-webkit-scrollbar-track { background: transparent; }
.sc-window *::-webkit-scrollbar-thumb { background: rgba(218, 165, 32, 0.25); border-radius: 2px; }
.sc-window *::-webkit-scrollbar-thumb:hover { background: rgba(218, 165, 32, 0.45); }
.sc-window * { scrollbar-width: thin; scrollbar-color: rgba(218, 165, 32, 0.25) transparent; }

/* ── Settlement Window ── */
.sett-window {
    height: 600px !important;
}
.sett-sidebar {
    width: 140px;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding-right: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sett-sidebar-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-title);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(218, 165, 32, 0.2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sett-sidebar-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: background 0.15s;
}
.sett-sidebar-tab:hover {
    background: rgba(255, 255, 255, 0.04);
}
.sett-sidebar-tab.active {
    background: rgba(218, 165, 32, 0.1);
    color: var(--text-title);
}
.sett-sidebar-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
}

/* ── Storage Window ── */
.stor-window .sc-header {
    display: flex;
    align-items: center;
}
.stor-window {
    height: 720px !important;
}
.stor-window .inv-slot {
    width: 58px;
    height: 58px;
}
.stor-window .storage-grid {
    grid-template-columns: repeat(auto-fill, 58px);
}
.stor-grids {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.stor-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 0 4px;
}
.stor-weight {
    font-size: 12px;
    text-align: right;
    padding: 4px 2px 0;
}
.stor-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 8px 0;
}

/* ── Storage rename ── */
.stor-rename-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    margin-left: 6px;
    line-height: 1;
    transition: color 0.15s;
}
.stor-rename-btn:hover { color: var(--text-title); }

.stor-rename-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 12px;
}
.stor-rename-box {
    background: var(--panel-bg, rgba(18, 14, 10, 0.97));
    border: 1px solid rgba(218, 165, 32, 0.3);
    border-radius: 8px;
    padding: 16px 20px;
    min-width: 260px;
    text-align: center;
}
.stor-rename-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-title);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.stor-rename-input {
    width: 100%;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(218, 165, 32, 0.25);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 12px;
}
.stor-rename-input:focus { border-color: var(--text-title); }
.stor-rename-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.stor-rename-actions .gm-detail-btn {
    min-width: 70px;
}

/* ── Build tab ── */
.gm-build-filter {
    width: 100%;
    padding: 6px 10px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}
.gm-build-filter:focus { border-color: var(--text-title); }
.gm-build-filter::placeholder { color: var(--text-secondary); }
.gm-build-content { overflow-y: auto; flex: 1; min-height: 0; }

/* ── Build tab: grid layout ── */
.gm-build-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--slot-size), 1fr));
    gap: 6px;
}
.gm-build-slot {
    width: var(--slot-size);
    height: var(--slot-size);
    background: var(--slot-bg);
    border: 1px solid var(--slot-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    overflow: hidden;
    position: relative;
}
.gm-build-slot:hover {
    border-color: var(--text-title);
    box-shadow: 0 0 10px rgba(232, 162, 58, 0.2);
}
.gm-build-slot.selected {
    border-color: var(--text-title);
    box-shadow: 0 0 12px rgba(232, 162, 58, 0.3);
    background: rgba(232, 162, 58, 0.08);
}
.gm-build-slot.locked {
    opacity: 0.4;
    cursor: default;
}
.gm-build-slot img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}
.gm-build-slot .gm-build-name {
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    font-size: 8px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.1;
    padding: 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gm-build-slot .gm-build-limit {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 9px;
    color: var(--text-dim);
}
.gm-build-slot .gm-build-limit.at-cap {
    color: #e74c3c;
}

.gm-detail-sheet-close,
.sc-detail-sheet-close,
.shop-detail-sheet-close {
    display: none;
}

/* ═══════════════════════════════════════
   MOBILE PORTRAIT: full-screen scrollable menu
   ═══════════════════════════════════════ */
@media (max-width: 600px) {
    .game-menu {
        width: 100vw;
        height: 100vh;
        top: 0;
        left: 0;
        transform: none !important;
        border-radius: 0;
        border: none;
    }
    .game-menu.open {
        flex-direction: column;
    }

    .game-menu-close {
        position: static;
        order: -1;
        font-size: 22px;
        padding: 6px 10px;
        flex-shrink: 0;
        border-right: 1px solid rgba(218, 165, 32, 0.2);
        position: sticky;
        left: 0;
        z-index: 10;
        background: rgba(10, 10, 20, 0.95);
    }

    /* Sidebar becomes horizontal top bar */
    .game-menu-sidebar {
        width: 100%;
        flex-direction: row;
        padding: 6px 0 6px 0;
        gap: 0;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: none;
        border-bottom: 1px solid rgba(218, 165, 32, 0.2);
        -webkit-overflow-scrolling: touch;
        flex-shrink: 0;
    }
    .game-menu-tab {
        flex-direction: column;
        padding: 6px 10px;
        min-width: 52px;
        border-left: none;
        border-bottom: 2px solid transparent;
        flex-shrink: 0;
    }
    .game-menu-tab.active {
        border-left-color: transparent;
        border-bottom-color: var(--text-title);
    }
    .gm-tab-icon {
        font-size: 18px;
        margin-bottom: 2px;
    }
    .gm-tab-label {
        font-size: 8px;
    }

    /* Body becomes single column, scrollable */
    .game-menu-body {
        flex-direction: column;
        padding: 12px;
        gap: 12px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .game-menu-main {
        max-height: none;
        overflow-y: visible;
    }

    /* Detail panel: hidden off-screen, slides up as bottom sheet */
    .game-menu-detail {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        max-height: 85vh;
        padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
        background: rgba(12, 12, 22, 0.97);
        border: none;
        border-top: 1px solid rgba(218, 165, 32, 0.3);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 50;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        pointer-events: none;
        max-height: 90vh;
    }
    .game-menu-detail.detail-open {
        transform: translateY(0);
        pointer-events: auto;
    }

    .gm-detail-sheet-close {
        display: block;
        position: sticky;
        top: 0;
        align-self: flex-end;
        background: none;
        border: none;
        color: var(--text-secondary);
        font-size: 24px;
        padding: 0 4px;
        cursor: pointer;
        z-index: 10;
        flex-shrink: 0;
    }

    .gm-detail-actions {
        margin-top: 12px;
        padding-bottom: 24px;
    }

    .gm-detail-content.active {
        flex: none;
        min-height: 0;
    }

    /* Equipment body: scale down for mobile */
    .equip-body {
        width: 200px;
        height: 350px;
    }
    .equip-body .equip-slot[data-slot="head"]     { top: 1px;    left: 74px; }
    .equip-body .equip-slot[data-slot="body"]     { top: 84px;   left: 72px; }
    .equip-body .equip-slot[data-slot="pants"]    { top: 194px;  left: 73px; }
    .equip-body .equip-slot[data-slot="hands"]    { top: 170px;  left: 8px; }
    .equip-body .equip-slot[data-slot="feet"]     { top: 306px;  left: 75px; }
    .equip-body .equip-slot[data-slot="backpack"] { top: 50px;   left: 168px; }

    /* Inventory grid: fewer columns */
    .gm-inventory-grid {
        grid-template-columns: repeat(5, var(--slot-size));
    }

    /* Skills: single column */
    .gm-skills-list {
        grid-template-columns: 1fr;
    }

    /* Station crafting window: same treatment */
    .sc-window {
        width: 100vw;
        height: 100vh;
        top: 0;
        left: 0;
        transform: none !important;
        border-radius: 0;
        border: none;
    }
    .sc-window.open {
        flex-direction: column;
    }
    .sc-body {
        flex-direction: column;
        padding: 12px;
        overflow-y: auto;
    }
    .sc-detail {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        min-width: 0;
        max-height: 90vh;
        padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
        background: rgba(12, 12, 22, 0.97);
        border: none;
        border-top: 1px solid rgba(218, 165, 32, 0.3);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 50;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        pointer-events: none;
    }
    .sc-detail.detail-open {
        transform: translateY(0);
        pointer-events: auto;
    }
    .sc-detail .gm-detail-actions {
        margin-top: 12px;
        padding-bottom: 24px;
    }
    .sc-detail-sheet-close {
        display: block !important;
        position: sticky;
        top: 0;
        align-self: flex-end;
        background: none;
        border: none;
        color: var(--text-secondary);
        font-size: 24px;
        padding: 0 4px;
        cursor: pointer;
        z-index: 10;
        flex-shrink: 0;
    }
    .sc-close {
        top: 8px;
        right: 10px;
        font-size: 28px;
        padding: 4px 10px;
    }
}

