/* Battle Vest Designer V2 - Visual Patchboard Layout */
/* To revert: change stylesheet link from vest-styles-v2.css to vest-styles.css */

#vest-view-v2 {
    min-height: 100vh;
    background: linear-gradient(180deg, #0a0a0a 0%, #1a1a1a 100%);
    padding-bottom: 40px;
}

/* Header */
#vest-view-v2 .vest-header {
    padding: 12px 15px;
    padding-top: 70px;
    border-bottom: 1px solid #222;
    text-align: center;
}

#vest-view-v2 .vest-header h1 {
    font-size: 24px;
    letter-spacing: 3px;
    margin-bottom: 4px;
    color: #fff;
}

#vest-view-v2 .vest-header .subtitle {
    color: #888;
    font-size: 12px;
}

/* Main Layout - Desktop: Three columns */
#vest-view-v2 .vest-main-layout {
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
    flex-wrap: wrap;
}

/* Left Column: Vest */
#vest-view-v2 .vest-column {
    flex: 1;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Middle Column: Patchboard */
#vest-view-v2 .patchboard-column {
    width: 350px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Right Column: Controls */
#vest-view-v2 .controls-sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ========== VEST CONTAINER ========== */
#vest-view-v2 .vest-container {
    position: relative;
    background: #0a0a0a;
    border: 2px solid #333;
    border-radius: 12px;
    padding: 15px;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#vest-view-v2 .vest-container.drag-over {
    border-color: #00ccff;
    box-shadow: 0 0 30px rgba(0, 204, 255, 0.4), inset 0 0 60px rgba(0, 204, 255, 0.1);
}

#vest-view-v2 .vest-image {
    max-width: 100%;
    max-height: 700px;
    object-fit: contain;
    position: relative;
    z-index: 1;
    pointer-events: none;
}

#vest-view-v2 .vest-patches-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* Vest Patch Items - clean, no selection indicators */
#vest-view-v2 .vest-patch-item {
    position: absolute;
    cursor: move;
    pointer-events: auto;
    user-select: none;
}

#vest-view-v2 .vest-patch-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* No visible selection state - controls only shown during active manipulation */
#vest-view-v2 .vest-patch-item.selected {
    z-index: 100;
}

/* Only show glow when actively being manipulated (resizing/rotating) */
#vest-view-v2 .vest-patch-item.manipulating {
    filter: drop-shadow(0 0 8px rgba(0, 204, 255, 0.6));
}

/* ========== PHOTOSHOP-STYLE HANDLES (Desktop) ========== */
/* Handles are HIDDEN by default - only shown during active manipulation */
#vest-view-v2 .patch-handles {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
}

/* Only show handles when actively dragging/manipulating */
#vest-view-v2 .vest-patch-item.manipulating .patch-handles {
    opacity: 1;
    visibility: visible;
}

/* Corner resize handles */
#vest-view-v2 .handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 1px solid #00ccff;
    pointer-events: auto;
    z-index: 10;
}

#vest-view-v2 .handle.corner {
    border-radius: 0;
}

#vest-view-v2 .handle.nw { top: 0; left: 0; cursor: nwse-resize; }
#vest-view-v2 .handle.ne { top: 0; right: 0; cursor: nesw-resize; }
#vest-view-v2 .handle.sw { bottom: 0; left: 0; cursor: nesw-resize; }
#vest-view-v2 .handle.se { bottom: 0; right: 0; cursor: nwse-resize; }

/* Rotation zones - invisible areas outside corners */
#vest-view-v2 .rotate-zone {
    position: absolute;
    width: 20px;
    height: 20px;
    pointer-events: auto;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M23 4v6h-6M1 20v-6h6M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"/></svg>'), auto;
    z-index: 11;
}

#vest-view-v2 .rotate-zone.nw { top: -20px; left: -20px; }
#vest-view-v2 .rotate-zone.ne { top: -20px; right: -20px; }
#vest-view-v2 .rotate-zone.sw { bottom: -20px; left: -20px; }
#vest-view-v2 .rotate-zone.se { bottom: -20px; right: -20px; }

/* Thin border around selected patch */
#vest-view-v2 .selection-border {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid rgba(0, 204, 255, 0.5);
    pointer-events: none;
}

/* ========== PATCHBOARD CONTAINER ========== */
#vest-view-v2 .patchboard-container {
    position: relative;
    background: #0a0a0a;
    border: 2px solid #333;
    border-radius: 12px;
    overflow: hidden;
    min-height: 400px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

/* Patchboard glow when dragging patch back */
#vest-view-v2 .patchboard-container.drag-over {
    border-color: #00ccff;
    box-shadow: 0 0 30px rgba(0, 204, 255, 0.4), inset 0 0 60px rgba(0, 204, 255, 0.1);
}

#vest-view-v2 .patchboard-header {
    background: linear-gradient(135deg, #2a1515 0%, #1a1a1a 100%);
    padding: 12px 15px;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

#vest-view-v2 .patchboard-header h3 {
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    margin: 0;
}

#vest-view-v2 .patch-count-badge {
    background: #ff4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
}

#vest-view-v2 .patchboard-wrapper {
    position: relative;
    width: 100%;
    min-height: 350px;
}

#vest-view-v2 .patchboard-image {
    width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
}

#vest-view-v2 .patchboard-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
}

/* Board Patch Items */
#vest-view-v2 .board-patch-item {
    position: absolute;
    cursor: grab;
    user-select: none;
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.2s, opacity 0.2s, filter 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#vest-view-v2 .board-patch-item:hover {
    transform: scale(1.05);
    z-index: 10;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
}

#vest-view-v2 .board-patch-item:active {
    cursor: grabbing;
}

#vest-view-v2 .board-patch-item img {
    width: 100%;
    height: calc(100% - 18px);
    object-fit: contain;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

#vest-view-v2 .board-patch-label {
    font-size: 9px;
    font-weight: bold;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 2px;
    margin-top: 2px;
    /* Hidden by default - shown after 3s hold */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
}

/* Show label when patch is held for 3+ seconds */
#vest-view-v2 .board-patch-item.show-label .board-patch-label {
    opacity: 1;
    visibility: visible;
}

/* Patch being dragged */
#vest-view-v2 .board-patch-item.dragging {
    opacity: 0.3;
}

/* Board patch manipulation state */
#vest-view-v2 .board-patch-item.manipulating {
    filter: drop-shadow(0 0 8px rgba(0, 204, 255, 0.6));
    z-index: 1000 !important;
}

/* Board patch handles - hidden by default */
#vest-view-v2 .board-patch-item .patch-handles {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
}

/* Show board patch handles when manipulating */
#vest-view-v2 .board-patch-item.manipulating .patch-handles {
    opacity: 1;
    visibility: visible;
}

/* Board patch handle corners */
#vest-view-v2 .board-patch-item .handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #fff;
    border: 1px solid #00ccff;
    pointer-events: auto;
    z-index: 10;
}

#vest-view-v2 .board-patch-item .handle.nw { top: 0; left: 0; cursor: nwse-resize; }
#vest-view-v2 .board-patch-item .handle.ne { top: 0; right: 0; cursor: nesw-resize; }
#vest-view-v2 .board-patch-item .handle.sw { bottom: 0; left: 0; cursor: nesw-resize; }
#vest-view-v2 .board-patch-item .handle.se { bottom: 0; right: 0; cursor: nwse-resize; }

/* Board patch rotation zones */
#vest-view-v2 .board-patch-item .rotate-zone {
    position: absolute;
    width: 16px;
    height: 16px;
    pointer-events: auto;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M23 4v6h-6M1 20v-6h6M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"/></svg>'), auto;
    z-index: 11;
}

#vest-view-v2 .board-patch-item .rotate-zone.nw { top: -16px; left: -16px; }
#vest-view-v2 .board-patch-item .rotate-zone.ne { top: -16px; right: -16px; }
#vest-view-v2 .board-patch-item .rotate-zone.sw { bottom: -16px; left: -16px; }
#vest-view-v2 .board-patch-item .rotate-zone.se { bottom: -16px; right: -16px; }

/* Board patch selection border */
#vest-view-v2 .board-patch-item .selection-border {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid rgba(0, 204, 255, 0.5);
    pointer-events: none;
}

/* ========== DRAG GHOST ========== */
.drag-ghost {
    position: fixed;
    width: 100px;
    height: 100px;
    pointer-events: none;
    z-index: 10000;
    opacity: 0.9;
    transform: rotate(-5deg);
    transition: transform 0.15s ease-out, filter 0.15s ease-out;
}

.drag-ghost img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

/* Glow when over vest */
.drag-ghost.over-vest {
    transform: rotate(0deg) scale(1.1);
}

.drag-ghost.over-vest img {
    filter: drop-shadow(0 0 20px rgba(0, 204, 255, 0.9)) drop-shadow(0 0 40px rgba(0, 204, 255, 0.5));
}

/* Glow when over patchboard (same effect!) */
.drag-ghost.over-board {
    transform: rotate(0deg) scale(1.1);
}

.drag-ghost.over-board img {
    filter: drop-shadow(0 0 20px rgba(0, 204, 255, 0.9)) drop-shadow(0 0 40px rgba(0, 204, 255, 0.5));
}

/* ========== CONTROL CARDS ========== */
#vest-view-v2 .control-card {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 12px;
}

#vest-view-v2 .control-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 12px;
    text-transform: uppercase;
    color: #fff;
}

/* Progress Card */
#vest-view-v2 .progress-card {
    background: linear-gradient(135deg, #2a1515 0%, #1a1a1a 100%);
    border-color: #3a2020;
}

#vest-view-v2 .progress-percent {
    font-size: 36px;
    font-weight: bold;
    text-align: center;
    margin: 5px 0;
    color: #ff6600;
}

#vest-view-v2 .progress-bar {
    width: 100%;
    height: 8px;
    background: #2a2a2a;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

#vest-view-v2 .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444 0%, #ff8844 100%);
    width: 0%;
    transition: width 0.5s ease;
}

#vest-view-v2 .progress-text {
    text-align: center;
    color: #888;
    font-size: 11px;
}

/* Patch Controls - Hidden by default, shown on desktop when patch selected */
#vest-view-v2 .patch-controls {
    display: none;
}

#vest-view-v2 .control-group {
    margin-bottom: 12px;
}

#vest-view-v2 .control-group label {
    display: block;
    font-size: 10px;
    font-weight: bold;
    color: #888;
    margin-bottom: 6px;
}

#vest-view-v2 .slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

#vest-view-v2 .slider-container input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: #2a2a2a;
    border-radius: 3px;
    outline: none;
}

#vest-view-v2 .slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #00ccff;
    border-radius: 50%;
    cursor: pointer;
}

#vest-view-v2 .slider-container span {
    min-width: 40px;
    text-align: right;
    color: #00ccff;
    font-size: 12px;
    font-weight: bold;
}

#vest-view-v2 .remove-btn {
    width: 100%;
    padding: 10px;
    background: #3a1515;
    color: #ff6666;
    border: 1px solid #4a2020;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
    transition: all 0.3s;
}

#vest-view-v2 .remove-btn:hover {
    background: #4a2020;
}

/* Public Toggle */
#vest-view-v2 .toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

#vest-view-v2 .toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: #2a2a2a;
    border-radius: 12px;
    transition: background 0.3s;
    flex-shrink: 0;
}

#vest-view-v2 .toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #666;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
}

#vest-view-v2 input[type="checkbox"] {
    display: none;
}

#vest-view-v2 input[type="checkbox"]:checked + .toggle-slider {
    background: #ff6600;
}

#vest-view-v2 input[type="checkbox"]:checked + .toggle-slider::before {
    left: 22px;
    background: #fff;
}

#vest-view-v2 .toggle-label {
    flex: 1;
}

#vest-view-v2 .toggle-label strong {
    display: block;
    font-size: 12px;
    margin-bottom: 2px;
    color: #fff;
}

#vest-view-v2 .toggle-label span {
    font-size: 10px;
    color: #888;
}

/* Action Buttons */
#vest-view-v2 .action-buttons {
    display: flex;
    gap: 10px;
}

#vest-view-v2 .save-btn {
    flex: 1;
    padding: 12px;
    background: linear-gradient(135deg, #006600 0%, #008800 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.3s;
}

#vest-view-v2 .save-btn:hover {
    background: linear-gradient(135deg, #007700 0%, #009900 100%);
    transform: translateY(-2px);
}

#vest-view-v2 .reset-btn {
    padding: 12px 16px;
    background: #2a2a2a;
    color: #ffaa00;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.3s;
}

#vest-view-v2 .reset-btn:hover {
    background: #3a3a3a;
}

/* Notification */
.vest-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: linear-gradient(135deg, #00aa00 0%, #008800 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    font-weight: bold;
    z-index: 10001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease;
}

.vest-notification.fade-out {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ========== MOBILE LAYOUT - All Elements Visible ========== */
@media (max-width: 1024px) {
    #vest-view-v2 {
        min-height: 100vh;
        padding-bottom: 0;
        display: flex;
        flex-direction: column;
    }

    #vest-view-v2 .vest-header {
        padding-top: 60px;
        padding-bottom: 6px;
        flex-shrink: 0;
    }

    #vest-view-v2 .vest-header h1 {
        font-size: 16px;
        margin-bottom: 2px;
    }

    #vest-view-v2 .vest-header .subtitle {
        font-size: 9px;
    }

    #vest-view-v2 .vest-main-layout {
        flex-direction: column;
        padding: 6px;
        gap: 6px;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    /* Vest takes ~42% of available space */
    #vest-view-v2 .vest-column {
        flex: 0 0 42%;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /* Patchboard takes ~42% of available space */
    #vest-view-v2 .patchboard-column {
        width: 100%;
        flex: 0 0 42%;
        min-height: 0;
    }

    #vest-view-v2 .vest-container {
        min-height: unset;
        height: 100%;
        padding: 6px;
        border-radius: 8px;
    }

    #vest-view-v2 .vest-image {
        max-height: 100%;
        object-fit: contain;
    }

    #vest-view-v2 .patchboard-container {
        min-height: unset;
        height: 100%;
        display: flex;
        flex-direction: column;
        border-radius: 8px;
    }

    #vest-view-v2 .patchboard-header {
        padding: 6px 10px;
        flex-shrink: 0;
    }

    #vest-view-v2 .patchboard-header h3 {
        font-size: 11px;
    }

    #vest-view-v2 .patchboard-wrapper {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        position: relative;
    }

    #vest-view-v2 .patchboard-image {
        position: absolute;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    #vest-view-v2 .patchboard-layer {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        padding: 6px;
    }

    /* Controls at bottom - compact single row */
    #vest-view-v2 .controls-sidebar {
        flex: 0 0 auto;
        flex-direction: row;
        gap: 6px;
        padding: 6px;
        background: #0a0a0a;
        border-top: 1px solid #222;
        order: 10;
    }

    /* Hide patch controls on mobile - use pinch gestures */
    #vest-view-v2 .patch-controls {
        display: none !important;
    }

    /* Hide public toggle on mobile to save space */
    #vest-view-v2 .public-toggle-card {
        display: none !important;
    }

    /* Progress card - compact */
    #vest-view-v2 .progress-card {
        flex: 1;
        padding: 8px;
        min-width: 0;
    }

    #vest-view-v2 .control-card-header {
        font-size: 9px;
        margin-bottom: 4px;
        gap: 4px;
    }

    #vest-view-v2 .progress-percent {
        font-size: 20px;
        margin: 2px 0;
    }

    #vest-view-v2 .progress-bar {
        height: 4px;
        margin: 4px 0;
    }

    #vest-view-v2 .progress-text {
        font-size: 8px;
    }

    /* Action buttons - compact */
    #vest-view-v2 .action-buttons {
        flex-direction: row;
        gap: 6px;
        flex: 0 0 auto;
    }

    #vest-view-v2 .save-btn {
        padding: 8px 12px;
        font-size: 11px;
    }

    #vest-view-v2 .reset-btn {
        padding: 8px 10px;
        font-size: 11px;
    }

    /* Patch items on board */
    #vest-view-v2 .board-patch-item {
        width: 50px !important;
        height: 60px !important;
    }

    #vest-view-v2 .board-patch-item img {
        height: calc(100% - 14px);
    }

    #vest-view-v2 .board-patch-label {
        font-size: 7px;
        padding: 1px 2px;
    }

    .drag-ghost {
        width: 60px;
        height: 60px;
    }

    .vest-notification {
        top: auto;
        bottom: 70px;
        right: 10px;
        left: 10px;
        text-align: center;
        padding: 10px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    #vest-view-v2 .vest-header {
        padding-top: 55px;
        padding-bottom: 4px;
    }

    #vest-view-v2 .vest-header h1 {
        font-size: 14px;
        letter-spacing: 1px;
    }

    #vest-view-v2 .vest-header .subtitle {
        font-size: 8px;
    }

    #vest-view-v2 .vest-main-layout {
        padding: 4px;
        gap: 4px;
    }

    #vest-view-v2 .vest-container,
    #vest-view-v2 .patchboard-container {
        border-radius: 6px;
    }

    #vest-view-v2 .board-patch-item {
        width: 42px !important;
        height: 52px !important;
    }

    #vest-view-v2 .board-patch-label {
        font-size: 6px;
    }

    #vest-view-v2 .controls-sidebar {
        padding: 4px 6px;
        gap: 4px;
    }

    #vest-view-v2 .progress-card {
        padding: 6px;
    }

    #vest-view-v2 .progress-percent {
        font-size: 18px;
    }

    #vest-view-v2 .save-btn,
    #vest-view-v2 .reset-btn {
        padding: 6px 8px;
        font-size: 10px;
    }

    .drag-ghost {
        width: 50px;
        height: 50px;
    }

    .vest-notification {
        bottom: 60px;
        padding: 8px 10px;
        font-size: 11px;
    }
}

/* Landscape mobile - side by side but smaller */
@media (max-width: 1024px) and (orientation: landscape) {
    #vest-view-v2 .vest-main-layout {
        flex-direction: row;
        flex-wrap: wrap;
    }

    #vest-view-v2 .vest-column {
        flex: 1 1 48%;
        max-width: 48%;
    }

    #vest-view-v2 .patchboard-column {
        flex: 1 1 48%;
        max-width: 48%;
    }

    #vest-view-v2 .controls-sidebar {
        flex: 0 0 100%;
        width: 100%;
    }
}

/* Scrollbar */
#vest-view-v2 ::-webkit-scrollbar {
    width: 8px;
}

#vest-view-v2 ::-webkit-scrollbar-track {
    background: #1a1a1a;
}

#vest-view-v2 ::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

#vest-view-v2 ::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* Touch action for mobile pinch/zoom */
#vest-view-v2 .vest-patch-item.touch-active {
    touch-action: none;
}

/* ========== MOBILE/DESKTOP LAYOUT SWITCHING ========== */
/* Hide mobile-only on desktop */
.mobile-only { display: none; }
.desktop-only { display: block; }
.vest-mobile-layout { display: none; }
.vest-desktop-layout { display: flex; }

/* ========== MOBILE LAYOUT STYLES ========== */
@media (max-width: 1024px) {
    .mobile-only { display: block; }
    .desktop-only { display: none !important; }
    .vest-mobile-layout { display: flex !important; }
    .vest-desktop-layout { display: none !important; }

    #vest-view-v2 {
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    #vest-view-v2 .vest-header {
        padding-top: 60px;
        padding-bottom: 8px;
        flex-shrink: 0;
    }

    /* Mobile Layout Container */
    .vest-mobile-layout {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 8px;
        gap: 8px;
    }

    /* Large Vest Area - takes most of the space */
    .mobile-vest-area {
        flex: 1;
        min-height: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-vest-area .vest-container {
        width: 100%;
        height: 100%;
        position: relative;
        background: #0a0a0a;
        border: 2px solid #333;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        transition: border-color 0.3s, box-shadow 0.3s;
    }

    .mobile-vest-area .vest-container.drag-over {
        border-color: #00ccff;
        box-shadow: 0 0 30px rgba(0, 204, 255, 0.4);
    }

    .mobile-vest-area .vest-image {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        pointer-events: none;
    }

    .mobile-vest-area .vest-patches-layer {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
    }

    /* Side-Scrollable Patchboard Strip */
    .mobile-patchboard-strip {
        flex-shrink: 0;
        height: 120px;
        border: 2px solid #333;
        border-radius: 10px;
        overflow: hidden;
        position: relative;
        background: url('assets/PATCHBOARD/Patchboard.jpg') center center;
        background-size: cover;
    }

    .patchboard-scroll-area {
        width: 100%;
        height: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .patchboard-scroll-area::-webkit-scrollbar {
        display: none;
    }

    .patchboard-scroll-track {
        position: relative;
        min-width: 100%;
        height: 100%;
        box-sizing: border-box;
    }

    /* Patchboard Patch Item - floats on velcro */
    .mobile-board-patch {
        position: absolute;
        width: 50px;
        height: 50px;
        cursor: pointer;
        transition: transform 0.15s ease, width 0.1s ease, height 0.1s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: none;
    }

    .mobile-board-patch:active:not(.dragging) {
        transform: scale(0.95);
    }

    .mobile-board-patch img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        pointer-events: none;
        filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));
    }

    .mobile-board-patch.on-vest {
        opacity: 0.35;
    }

    .mobile-board-patch.on-vest::after {
        content: '✓';
        position: absolute;
        top: -2px;
        right: -2px;
        background: #00aa00;
        color: white;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        font-size: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
    }

    .mobile-board-patch.dragging {
        opacity: 0.8;
        transform: scale(1.1);
        z-index: 1000 !important;
        filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
    }

    /* Mobile Action Buttons */
    .mobile-action-buttons {
        flex-shrink: 0;
        display: flex;
        gap: 8px;
        padding: 4px 0;
    }

    .mobile-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 4px;
        border-radius: 8px;
        border: 1px solid #333;
        background: #1a1a1a;
        color: #fff;
        cursor: pointer;
        transition: all 0.2s;
        min-height: 50px;
    }

    .mobile-btn:active {
        transform: scale(0.95);
        background: #2a2a2a;
    }

    .mobile-btn .btn-icon {
        font-size: 18px;
        margin-bottom: 2px;
    }

    .mobile-btn .btn-label {
        font-size: 9px;
        font-weight: bold;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .mobile-btn .btn-value,
    .mobile-btn .btn-status {
        font-size: 11px;
        font-weight: bold;
        color: #ff6600;
    }

    .mobile-btn.score-btn {
        background: linear-gradient(135deg, #2a1515 0%, #1a1a1a 100%);
        border-color: #3a2020;
    }

    .mobile-btn.save-btn {
        background: linear-gradient(135deg, #152a15 0%, #1a1a1a 100%);
        border-color: #203a20;
    }

    .mobile-btn.save-btn .btn-icon { color: #44ff44; }

    .mobile-btn.reset-btn {
        background: linear-gradient(135deg, #2a2a15 0%, #1a1a1a 100%);
        border-color: #3a3a20;
    }

    .mobile-btn.reset-btn .btn-icon { color: #ffaa44; }

    .mobile-btn.public-btn {
        background: linear-gradient(135deg, #15152a 0%, #1a1a1a 100%);
        border-color: #20203a;
    }

    .mobile-btn.public-btn .btn-icon { color: #4488ff; }

    .mobile-btn.public-btn.active {
        border-color: #00ccff;
        background: linear-gradient(135deg, #152a2a 0%, #1a1a1a 100%);
    }

    .mobile-btn.public-btn.active .btn-status {
        color: #00ccff;
    }

    /* Mobile vest patches */
    .mobile-vest-area .vest-patch-item {
        position: absolute;
        cursor: move;
        pointer-events: auto;
        user-select: none;
        touch-action: none;
    }

    .mobile-vest-area .vest-patch-item img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        pointer-events: none;
    }

    .mobile-vest-area .vest-patch-item.selected {
        z-index: 100;
        filter: drop-shadow(0 0 10px rgba(0, 204, 255, 0.8));
    }

    .mobile-vest-area .vest-patch-item.dragging {
        opacity: 0.5;
        z-index: 1000;
    }

    /* Vest container glow when dragging outside */
    .mobile-vest-area .vest-container.drag-over {
        border-color: #ff6600;
        box-shadow: 0 0 20px rgba(255, 102, 0, 0.5);
    }
}

/* Small mobile adjustments */
@media (max-width: 480px) {
    .mobile-patch-carousel {
        height: 80px;
    }

    .carousel-patch {
        width: 60px;
        height: 60px;
    }

    .mobile-btn {
        min-height: 45px;
        padding: 6px 2px;
    }

    .mobile-btn .btn-icon {
        font-size: 16px;
    }

    .mobile-btn .btn-label {
        font-size: 8px;
    }

    .mobile-btn .btn-value,
    .mobile-btn .btn-status {
        font-size: 10px;
    }
}
