@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Orbitron:wght@700;900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

:root {
    --sky-blue: #c8e6f5;
    --panel-bg: rgba(255, 255, 255, 0.95);
    --popup-bg: rgba(180, 220, 240, 0.85);
    --popup-border: rgba(255, 255, 255, 0.6);
    --accent-pink: #ff4d6d;
    --accent-cyan: #4dd4e8;
    --accent-blue: #5b7fff;
    --text-dark: #2d3436;
    --text-muted: #636e72;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --shadow-strong: 0 8px 40px rgba(0, 0, 0, 0.2);
}

body {
    font-family: 'Nunito', sans-serif;
    background: var(--sky-blue);
    color: var(--text-dark);
    overflow: hidden;
    height: 100vh;
}

#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ============ TOP MENU BAR ============ */
.top-menu {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: var(--panel-bg);
    border-radius: 30px;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: var(--shadow);
}

.menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu-btn:hover {
    background: rgba(93, 127, 255, 0.1);
    color: var(--accent-blue);
}

.menu-btn.danger {
    color: var(--accent-pink);
}

.menu-btn.danger:hover {
    background: rgba(255, 77, 109, 0.1);
}

.menu-btn.active {
    background: var(--accent-blue);
    color: white;
}

.menu-btn svg {
    width: 16px;
    height: 16px;
}

.menu-divider {
    width: 1px;
    height: 25px;
    background: #ddd;
    margin: 0 5px;
}

/* ============ MENU DROPDOWN ============ */
.menu-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
    margin-top: 8px;
    padding: 8px;
}

.dropdown-menu.show {
    display: block;
    animation: dropdownFade 0.25s ease;
}

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

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: #f5f5f5;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    text-align: left;
    transition: all 0.2s ease;
    margin-bottom: 6px;
    position: relative;
}

.dropdown-item:last-child {
    margin-bottom: 0;
}

.dropdown-item:hover {
    background: #e8f0fe;
    color: var(--accent-blue);
}

.dropdown-item.active {
    background: var(--accent-blue);
    color: white;
}

.dropdown-item.active .dropdown-icon,
.dropdown-item.active .dropdown-arrow {
    color: white;
}

.dropdown-icon {
    font-size: 16px;
    color: var(--accent-blue);
    min-width: 20px;
    text-align: center;
}

.dropdown-arrow {
    margin-left: auto;
    color: #999;
    font-size: 16px;
}

.dropdown-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 10px 0;
}

.dropdown-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 16px 4px;
}

.dropdown-slider-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 16px;
    background: #f5f5f5;
    border-radius: 12px;
    margin-bottom: 6px;
}

.dropdown-slider-item span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
}

.dropdown-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.dropdown-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(93, 127, 255, 0.4);
}

.dropdown-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    border: none;
}

/* ============ GROUPS DROPDOWN ============ */
.groups-dropdown {
    min-width: 280px;
    max-height: 400px;
    overflow-y: auto;
}

.groups-list {
    max-height: 300px;
    overflow-y: auto;
}

.no-groups {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 13px;
    font-style: italic;
}

.group-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f5f5f5;
    border-radius: 10px;
    margin-bottom: 6px;
    transition: all 0.2s;
    cursor: pointer;
}

.group-item:hover {
    background: #e8f0fe;
}

.group-item.selected {
    background: linear-gradient(135deg, #00d9ff22 0%, #00ffcc22 100%);
    border: 2px solid var(--accent-cyan);
}

.group-item.hidden {
    opacity: 0.5;
}

.group-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.group-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-count {
    font-size: 11px;
    color: #999;
    background: #e0e0e0;
    padding: 2px 6px;
    border-radius: 10px;
}

.group-actions {
    display: flex;
    gap: 4px;
}

.group-action-btn {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.group-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.group-action-btn.visibility {
    color: var(--accent-blue);
}

.group-action-btn.visibility.hidden {
    color: #999;
}

.group-action-btn.select {
    color: #27ae60;
}

.group-action-btn.select:hover {
    background: rgba(39, 174, 96, 0.2);
}

.group-action-btn.edit-bricks {
    color: #e67e22;
}

.group-action-btn.edit-bricks:hover {
    background: rgba(230, 126, 34, 0.2);
}

.group-action-btn.rename {
    color: var(--accent-cyan);
}

.group-action-btn.delete {
    color: var(--accent-pink);
}

/* Modal pour créer/éditer groupe */
.group-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.group-modal.show {
    display: flex;
}

.group-modal-content {
    background: white;
    border-radius: 20px;
    padding: 25px;
    min-width: 320px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalFade 0.3s ease;
}

.duplicate-modal-content {
    border-top: 4px solid var(--accent-cyan);
}

.duplicate-modal-text {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
}

@keyframes modalFade {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.group-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 20px;
}

.group-modal-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    margin-bottom: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.group-modal-input:focus {
    border-color: var(--accent-blue);
}

.group-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.group-modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.group-modal-btn.cancel {
    background: #e0e0e0;
    color: var(--text-dark);
}

.group-modal-btn.confirm {
    background: var(--accent-blue);
    color: white;
}

.group-modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ============ LEFT HEXAGON PANEL ============ */
.left-panel {
    position: fixed;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hex-btn {
    width: 70px;
    height: 80px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.hex-btn:hover {
    transform: scale(1.1);
    filter: drop-shadow(0 6px 15px rgba(0, 0, 0, 0.3));
}

.hex-btn.active {
    transform: scale(1.1);
}

.hex-bg {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.hex-btn:nth-child(1) .hex-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.hex-btn:nth-child(2) .hex-bg {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.hex-btn:nth-child(3) .hex-bg {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.hex-btn:nth-child(4) .hex-bg {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.hex-btn:nth-child(5) .hex-bg {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.hex-btn:nth-child(6) .hex-bg {
    background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
}

.hex-btn:nth-child(7) .hex-bg {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

/* ============ POPUP SUBMENU ============ */
.popup-menu {
    position: fixed;
    left: 100px;
    top: 50%;
    transform: translateY(-50%);
    width: 420px;
    max-height: 500px;
    background: var(--popup-bg);
    backdrop-filter: blur(20px);
    border: 2px solid var(--popup-border);
    border-radius: 20px;
    padding: 15px;
    z-index: 150;
    display: none;
    box-shadow: var(--shadow-strong);
}

.popup-menu.active {
    display: block;
    animation: popIn 0.2s ease;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    margin-bottom: 10px;
}

.popup-tabs {
    display: none;
    /* Caché - remplacé par le select */
    gap: 5px;
    margin-bottom: 10px;
}

.popup-tab {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.3);
    color: var(--text-dark);
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.popup-tab:hover {
    background: rgba(255, 255, 255, 0.5);
}

.popup-tab.active {
    background: var(--accent-blue);
    color: white;
}

.popup-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
}

.popup-filter {
    display: flex;
    gap: 10px;
    align-items: center;
}

.popup-filter select {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.7);
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    min-width: 150px;
}

.popup-filter select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Select pour les sous-catégories (onglets) */
#popup-tab-select {
    padding: 8px 12px;
    border-radius: 10px;
    border: 2px solid var(--accent-blue);
    background: white;
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    min-width: 160px;
    color: var(--accent-blue);
}

.popup-grid-container {
    position: relative;
}

.popup-grid-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, rgba(180, 220, 240, 0.95));
    pointer-events: none;
    border-radius: 0 0 10px 10px;
}

.popup-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-height: 350px;
    overflow-y: auto;
    padding: 5px;
    padding-bottom: 30px;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.popup-grid::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Opera */
}

.popup-item {
    aspect-ratio: 1;
    background: rgba(100, 200, 255, 0.4);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dark);
    flex-direction: column;
    gap: 5px;
    padding: 8px;
}

.popup-item:hover {
    background: rgba(100, 200, 255, 0.6);
    border-color: white;
    transform: scale(1.05);
}

.popup-item.active {
    border-color: var(--accent-blue);
    background: rgba(93, 127, 255, 0.3);
}

.popup-item-icon {
    font-size: 28px;
}

.popup-item-label {
    font-size: 10px;
    text-align: center;
}

.popup-footer {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.popup-btn {
    padding: 10px 30px;
    border: none;
    border-radius: 25px;
    font-family: 'Nunito', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.popup-btn.confirm {
    background: var(--accent-cyan);
    color: white;
}

.popup-btn.cancel {
    background: var(--accent-pink);
    color: white;
}

.popup-btn:hover {
    transform: scale(1.05);
}

/* ============ BOTTOM COLOR PANEL ============ */
.bottom-panel {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: var(--panel-bg);
    border-radius: 30px;
    padding: 9px 19px;
    display: flex;
    align-items: center;
    gap: 9px;
    box-shadow: var(--shadow);
}

.color-btn {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.color-btn:hover {
    transform: scale(1.2);
}

.color-btn.active {
    border-color: var(--text-dark);
    transform: scale(1.15);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.color-btn.transparent-pattern {
    background:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}

.color-divider {
    width: 1px;
    height: 22px;
    background: #ddd;
    margin: 0 4px;
}

.color-picker-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px dashed #aaa;
    cursor: pointer;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.color-picker-btn:hover {
    transform: scale(1.2);
    border-style: solid;
}

.color-picker-btn input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Transparency slider */
.transparency-control {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
}

.transparency-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}

.transparency-slider {
    width: 60px;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, transparent, #333);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.transparency-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--accent-blue);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.transparency-value {
    font-size: 9px;
    font-weight: 700;
    color: var(--accent-blue);
    min-width: 26px;
}

.brilliance-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brilliance-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}

.brilliance-slider {
    width: 50px;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #333, #fff);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.brilliance-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    border: 2px solid #FFD700;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#brilliance-color {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
}

#brilliance-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

#brilliance-color::-webkit-color-swatch {
    border: 2px solid #ddd;
    border-radius: 50%;
}

.selected-color-preview {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    border: 2px solid var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(91, 127, 255, 0.3);
    position: relative;
}

.selected-color-preview.has-transparency {
    background:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}

.selected-color-preview .color-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
}

/* ============ COLOR PALETTE POPUP ============ */
.color-palette-popup {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    border-radius: 20px;
    padding: 20px;
    z-index: 200;
    display: none;
    box-shadow: var(--shadow-strong);
}

.color-palette-popup.active {
    display: block;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============ RIGHT INFO PANEL ============ */
.right-panel {
    position: fixed;
    right: 15px;
    top: 80px;
    z-index: 100;
    background: var(--panel-bg);
    border-radius: 15px;
    padding: 15px;
    min-width: 180px;
    box-shadow: var(--shadow);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.info-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-blue);
}

/* Stud Culling Economy Counter */
.economy-row {
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.1) 0%, rgba(46, 204, 113, 0.1) 100%);
    border-radius: 8px;
    margin-top: 5px;
    padding: 8px 10px !important;
}

.economy-value {
    color: #27ae60;
    font-weight: 800;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(39, 174, 96, 0.2);
}

/* ============ LOGO ============ */
.logo {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 100;
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 2px;
}

/* ============ INSTRUCTIONS ============ */
.instructions {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99;
    display: flex;
    gap: 15px;
    font-size: 11px;
    color: var(--text-muted);
}

.instruction {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.8);
    padding: 5px 12px;
    border-radius: 15px;
}

.key {
    background: #e0e0e0;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 10px;
}

/* ============ SELECTION BOX ============ */
.selection-info {
    position: fixed;
    top: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    border-radius: 15px;
    padding: 10px 20px;
    display: none;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
    z-index: 100;
}

.selection-info.active {
    display: flex;
}

.group-name-inline {
    padding: 6px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 600;
    width: 140px;
    outline: none;
    transition: border-color 0.2s;
}

.group-name-inline:focus {
    border-color: var(--accent-blue);
}

/* ============ GROUP CONTROL PANEL ============ */
.group-control-panel {
    display: none;
    position: fixed;
    top: 200px;
    right: 20px;
    background: var(--panel-bg);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 150;
    min-width: 200px;
}

.group-control-panel.active {
    display: block;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

.group-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.group-control-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-blue);
}

.group-control-close {
    width: 24px;
    height: 24px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: all 0.2s;
}

.group-control-close:hover {
    background: var(--accent-pink);
    color: white;
}

.group-control-section {
    margin-bottom: 12px;
}

.group-control-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.group-control-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.ctrl-btn {
    padding: 8px 6px;
    border: none;
    border-radius: 8px;
    background: #f0f0f0;
    font-family: 'Nunito', sans-serif;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ctrl-btn:hover {
    background: var(--accent-blue);
    color: white;
    transform: scale(1.05);
}

.ctrl-btn.rotate-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ctrl-btn.rotate-btn:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.selection-count,
.edit-selection-count {
    font-weight: 700;
    color: var(--accent-blue);
}

/* Edit Selection Info Bar */
.edit-selection-info {
    position: fixed;
    top: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
    border-radius: 15px;
    padding: 10px 20px;
    display: none;
    align-items: center;
    gap: 15px;
    box-shadow: 0 8px 25px rgba(230, 126, 34, 0.3);
    z-index: 100;
    color: white;
}

.edit-selection-info.active {
    display: flex;
}

.edit-selection-count {
    color: white;
}

.edit-group-name {
    font-weight: 700;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

/* Group Selection Bar (groupe sélectionné) */
.group-selection-info {
    position: fixed;
    top: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    border-radius: 15px;
    padding: 10px 20px;
    display: none;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.3);
    z-index: 100;
    color: white;
}

.group-selection-info.active {
    display: flex;
}

.group-selection-name {
    font-weight: 700;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

.group-selection-count {
    font-size: 12px;
    opacity: 0.9;
}

.selection-btn {
    padding: 6px 15px;
    border: none;
    border-radius: 15px;
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.selection-btn.group {
    background: var(--accent-cyan);
    color: white;
}

.selection-btn.delete {
    background: var(--accent-pink);
    color: white;
}

.selection-btn.cancel {
    background: #ddd;
    color: var(--text-dark);
}

/* Tooltip Collision */
.collision-tooltip {
    position: fixed;
    background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.4);
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s;
    z-index: 3000;
}

.collision-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

/* Lasso Selection Rectangle */
.lasso-rect {
    position: fixed;
    border: 2px dashed var(--accent-cyan);
    background: rgba(0, 255, 255, 0.1);
    pointer-events: none;
    z-index: 1000;
    display: none;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.lasso-rect.active {
    display: block;
}

/* ============ TEST DRIVE MODE ============ */
.test-drive-btn {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 100;
    padding: 15px 30px;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(74, 222, 128, 0.4);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.test-drive-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(74, 222, 128, 0.6);
}

.test-drive-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.test-drive-hud {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    padding: 20px 40px;
    display: none;
    gap: 40px;
    color: white;
}

.test-drive-hud.active {
    display: flex;
}

.hud-item {
    text-align: center;
}

.hud-label {
    font-size: 11px;
    opacity: 0.7;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.hud-value {
    font-size: 24px;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
}

.hud-speed-bar {
    width: 150px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}

.hud-speed-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #fbbf24, #ef4444);
    border-radius: 4px;
    transition: width 0.1s;
}

.hud-life-bar {
    width: 150px;
    height: 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    margin-top: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.hud-life-fill {
    height: 100%;
    background: linear-gradient(90deg, #ef4444, #f87171);
    border-radius: 5px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.hud-life .hud-value {
    color: #ff6b6b;
}

.hud-life-critical .hud-life-fill {
    animation: pulse-life 0.5s infinite;
}

@keyframes pulse-life {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.test-drive-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px 20px;
    font-size: 12px;
    display: none;
}

.test-drive-controls.active {
    display: block;
}

.test-drive-controls h3 {
    margin-bottom: 10px;
    font-size: 14px;
    color: #22c55e;
}

.control-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin: 5px 0;
}

.exit-test-btn {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    padding: 10px 25px;
    background: #ef4444;
    border: none;
    border-radius: 20px;
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: none;
}

.exit-test-btn.active {
    display: block;
}

.camera-mode-display {
    position: fixed;
    top: 80px;
    left: 20px;
    z-index: 200;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 600;
    display: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.camera-mode-display.active {
    display: block;
}

/* ============ FENÊTRE RÉGLAGE ROUES ============ */
.wheel-settings-modal {
    position: fixed;
    top: 120px;
    left: 100px;
    z-index: 500;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 25px 30px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    display: none;
    min-width: 320px;
}

.wheel-settings-modal.active {
    display: block;
}

.wheel-settings-modal h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    color: #2d3436;
    margin-bottom: 20px;
    text-align: center;
    border-bottom: 2px solid #4ade80;
    padding-bottom: 10px;
}

.wheel-setting-group {
    margin-bottom: 15px;
}

.wheel-setting-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}

.wheel-setting-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

.wheel-setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4ade80;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.wheel-setting-value {
    display: inline-block;
    font-size: 12px;
    color: #4ade80;
    font-weight: 700;
    float: right;
}

.wheel-settings-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.wheel-settings-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.wheel-btn-cancel {
    background: #e74c3c;
    color: white;
}

.wheel-btn-cancel:hover {
    background: #c0392b;
}

.wheel-btn-apply {
    background: #4ade80;
    color: white;
}

.wheel-btn-apply:hover {
    background: #22c55e;
}

.wheel-settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 499;
    display: none;
}

.wheel-settings-overlay.active {
    display: block;
}

/* ============ LIBRARY DROPDOWN ============ */
.library-dropdown {
    min-width: 320px;
    max-height: 450px;
    overflow-y: auto;
}

.library-list {
    max-height: 350px;
    overflow-y: auto;
    padding: 4px;
}

.no-library-items {
    padding: 25px;
    text-align: center;
    color: #999;
    font-size: 13px;
    font-style: italic;
}

.library-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.library-item:hover {
    background: linear-gradient(135deg, #e8f4fd 0%, #d0ebff 100%);
    border-color: var(--accent-cyan);
    transform: translateX(4px);
}

.library-item.selected {
    background: linear-gradient(135deg, #d0f0ff 0%, #a5e3ff 100%);
    border-color: var(--accent-blue);
}

.library-item-icon {
    font-size: 28px;
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.library-item-info {
    flex: 1;
    min-width: 0;
}

.library-item-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-item-meta {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.library-item-actions {
    display: flex;
    gap: 4px;
}

.library-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.15s ease;
}

.library-action-btn:hover {
    transform: scale(1.1);
}

.library-action-btn.select {
    color: #27ae60;
}

.library-action-btn.select:hover {
    background: rgba(39, 174, 96, 0.2);
}

.library-action-btn.rename {
    color: var(--accent-blue);
}

.library-action-btn.rename:hover {
    background: rgba(93, 127, 255, 0.2);
}

.library-action-btn.delete {
    color: var(--accent-pink);
}

.library-action-btn.delete:hover {
    background: rgba(255, 77, 109, 0.2);
}

/* ============ COMPILE BUTTON STYLE ============ */
.dropdown-item.compile {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 700;
}

.dropdown-item.compile:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
    transform: scale(1.02);
}

.dropdown-item.compile span {
    font-size: 16px;
}

/* ============ LIBRARY PLACEMENT INDICATOR ============ */
.library-placement-active {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 700;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.library-placement-active .key-hint {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
}

/* ============ LIBRARY MODAL (BIBLIOTHÈQUE) ============ */
/* Overlay backdrop */
.library-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.library-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Modal container - perfectly centered */
.library-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 2600;

    /* Dimensions for 8x4 grid */
    width: 860px;
    max-width: 90vw;

    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);

    opacity: 0;
    visibility: hidden;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.library-modal.visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Modal header */
.library-modal-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: relative;
}

.library-modal-title {
    font-family: 'Nunito', sans-serif;
    font-size: 22px;
    font-weight: 800;
    margin: 0;
}

.library-modal-subtitle {
    font-size: 13px;
    opacity: 0.85;
    font-weight: 600;
}

.library-modal-close {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.library-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

/* Grid container - fixed height for exactly 4 rows */
.library-modal-grid-container {
    padding: 20px;
    /* Height calculated for exactly 4 rows: 4 * (item height ~100px) + gaps */
    height: 460px;
    overflow: hidden;
    position: relative;
}

/* The grid itself - 8 columns layout */
.library-modal-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 12px;
    height: 100%;
    overflow-y: auto;
    padding-right: 5px;

    /* ============ TRANSPARENT SCROLLBAR HACK ============ */
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;

    /* Smooth scrolling */
    scroll-behavior: smooth;
}

/* Webkit browsers (Chrome, Safari, Edge) - Invisible scrollbar */
.library-modal-grid::-webkit-scrollbar {
    width: 8px;
}

.library-modal-grid::-webkit-scrollbar-track {
    background: transparent;
}

.library-modal-grid::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
    transition: background 0.3s;
}

/* Show subtle scrollbar on hover */
.library-modal-grid:hover::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
}

.library-modal-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Empty state */
.library-empty-state {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #999;
    font-size: 16px;
    font-style: italic;
    text-align: center;
}

/* Individual grid item */
.library-grid-item {
    aspect-ratio: 1;
    background: linear-gradient(145deg, #f5f7ff 0%, #e8ecff 100%);
    border: 2px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    position: relative;
    overflow: hidden;
}

.library-grid-item:hover {
    border-color: var(--accent-blue);
    background: linear-gradient(145deg, #eef1ff 0%, #dce3ff 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.25);
}

.library-grid-item.selected {
    border-color: var(--accent-cyan);
    background: linear-gradient(145deg, #e0f7ff 0%, #b8f0ff 100%);
    box-shadow: 0 0 0 3px rgba(77, 212, 232, 0.3);
}

/* Item icon */
.library-grid-item-icon {
    font-size: 32px;
    margin-bottom: 6px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Item name */
.library-grid-item-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dark);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
}

/* Item meta info */
.library-grid-item-meta {
    font-size: 9px;
    color: #888;
    margin-top: 2px;
}

/* Delete button on item hover */
.library-grid-item-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 77, 109, 0.9);
    color: white;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-grid-item:hover .library-grid-item-delete {
    opacity: 1;
    transform: scale(1);
}

.library-grid-item-delete:hover {
    background: var(--accent-pink);
    transform: scale(1.1);
}

/* Modal footer */
.library-modal-footer {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px 25px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: #f8f9ff;
}

.library-modal-btn {
    padding: 12px 35px;
    border: none;
    border-radius: 25px;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.library-modal-btn.cancel {
    background: linear-gradient(135deg, #ff6b8a 0%, #ff4d6d 100%);
    color: white;
}

.library-modal-btn.cancel:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 77, 109, 0.4);
}

.library-modal-btn.confirm {
    background: linear-gradient(135deg, #4dd4e8 0%, #00bcd4 100%);
    color: white;
}

.library-modal-btn.confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(77, 212, 232, 0.4);
}

/* ============ FILE NOTIFICATIONS ============ */
.file-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: rgba(45, 52, 54, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100000;
    opacity: 0;
    transition: all 0.3s ease;
    color: #fff;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 600;
}

.file-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.file-notification-success {
    border-left: 4px solid #00d26a;
}

.file-notification-error {
    border-left: 4px solid #ff4757;
}

.file-notification-warning {
    border-left: 4px solid #ffa502;
}

.file-notification-info {
    border-left: 4px solid #3498db;
}

/* ============ LIBRARY POPUP ============ */
.library-popup {
    position: fixed;
    left: 100px;
    top: 50%;
    transform: translateY(-50%);
    width: 320px;
    max-height: 450px;
    background: linear-gradient(135deg, #e8f4fc 0%, #d1e9f6 100%);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.8);
}

.library-popup.active {
    display: flex;
}

.library-popup-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.library-popup-title {
    font-size: 16px;
    font-weight: bold;
}

.library-popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    max-height: 300px;
}

.library-popup-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.library-popup .library-item {
    position: relative;
    aspect-ratio: 1;
    background: rgba(100, 200, 255, 0.4);
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
    transition: all 0.2s;
}

.library-popup .library-item:hover {
    background: rgba(100, 200, 255, 0.6);
    border-color: white;
    transform: scale(1.05);
}

.library-popup .library-item.selected {
    border: 3px solid #5b7fff;
    background: rgba(93, 127, 255, 0.3);
    box-shadow: 0 0 8px rgba(93, 127, 255, 0.5);
}

.library-item-preview {
    font-size: 24px;
    pointer-events: none;
}

.library-popup .library-item-name {
    font-size: 8px;
    font-weight: 600;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    pointer-events: none;
}

.library-empty-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px 15px;
    color: #888;
}

.library-empty-message span {
    font-size: 40px;
    display: block;
    margin-bottom: 8px;
}

.library-empty-message p {
    font-size: 12px;
    margin: 0;
    color: #666;
}

.library-empty-message small {
    font-size: 10px;
    color: #aaa;
}

.library-popup-footer {
    padding: 12px;
    background: rgba(255, 255, 255, 0.5);
    display: flex;
    gap: 8px;
    justify-content: center;
}

.library-popup-footer .popup-btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
}

.library-popup-footer .popup-btn.cancel {
    background: #ff6b6b;
    color: white;
}

.library-popup-footer .popup-btn.confirm {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.library-item-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 9px;
    cursor: pointer;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-popup .library-item:hover .library-item-delete {
    opacity: 1;
}

/* ============ MODE CONDUITE RÉALISTE (CANNON.JS) ============ */

/* Bouton Conduite Réaliste */
.cannon-drive-btn {
    position: fixed;
    bottom: 160px;
    right: 30px;
    z-index: 100;
    padding: 15px 30px;
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cannon-drive-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(139, 92, 246, 0.6);
}

.cannon-drive-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Bouton Quitter Cannon */
.exit-cannon-btn {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    padding: 12px 30px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: none;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    transition: all 0.3s;
}

.exit-cannon-btn:hover {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);
}

.exit-cannon-btn.active {
    display: block;
}

/* HUD Cannon Drive */
.cannon-hud {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: linear-gradient(135deg, rgba(109, 40, 217, 0.9), rgba(139, 92, 246, 0.9));
    border-radius: 20px;
    padding: 20px 30px;
    display: none;
    flex-direction: column;
    gap: 12px;
    color: white;
    min-width: 200px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 40px rgba(109, 40, 217, 0.5);
}

.cannon-hud.active {
    display: flex;
}

.cannon-hud-title {
    text-align: center;
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    margin-bottom: 5px;
}

.cannon-hud-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.cannon-label {
    font-size: 11px;
    text-transform: uppercase;
    opacity: 0.8;
    min-width: 60px;
}

.cannon-value {
    font-size: 28px;
    font-weight: 800;
    font-family: 'Orbitron', monospace;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.cannon-unit {
    font-size: 12px;
    opacity: 0.7;
}

.cannon-gear {
    font-size: 32px;
    color: #fbbf24;
}

.cannon-rpm-bar {
    flex: 1;
    height: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    overflow: hidden;
}

.cannon-rpm-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e, #fbbf24, #ef4444);
    border-radius: 5px;
    transition: width 0.1s;
}

/* Contrôles Cannon Drive */
.cannon-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    background: linear-gradient(135deg, rgba(109, 40, 217, 0.95), rgba(139, 92, 246, 0.95));
    border-radius: 15px;
    padding: 15px 20px;
    font-size: 12px;
    display: none;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 5px 20px rgba(109, 40, 217, 0.4);
}

.cannon-controls.active {
    display: block;
}

.cannon-controls h3 {
    margin-bottom: 10px;
    font-size: 14px;
    color: #fbbf24;
    text-align: center;
}

.cannon-controls .control-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin: 5px 0;
    color: white;
}

.cannon-controls .key {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-family: monospace;
}

/* ============ NATURE PHYSICS SELECTOR ============ */
.nature-physics-selector {
    display: flex;
    gap: 6px;
    margin-left: 12px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    align-items: center;
}

.physics-radio {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: transparent;
}

.physics-radio:hover {
    background: rgba(255, 255, 255, 0.2);
}

.physics-radio input[type="radio"] {
    display: none;
}

.physics-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.physics-radio input[type="radio"]:checked+.physics-label {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 5px 12px;
    border-radius: 8px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* État Fantôme - Cyan */
.physics-radio input[value="ghost"]:checked+.physics-label {
    background: linear-gradient(135deg, #00d9ff 0%, #00ffcc 100%);
    box-shadow: 0 2px 8px rgba(0, 217, 255, 0.4);
}

/* État Solide - Vert */
.physics-radio input[value="solid"]:checked+.physics-label {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.4);
}

/* État Destructible - Orange/Rouge */
.physics-radio input[value="destructible"]:checked+.physics-label {
    background: linear-gradient(135deg, #e74c3c 0%, #f39c12 100%);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
}

/* ============ ECONOMY COUNTER ============ */
.economy-row {
    background: linear-gradient(135deg, #00d9ff22 0%, #00ffcc22 100%);
    border-radius: 8px;
    padding: 6px 10px !important;
    margin-top: 5px;
}

.economy-value {
    color: #27ae60 !important;
    font-weight: 800 !important;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}