/* Cube Solver 3D - Scoped Styles */
.cube-app-wrapper {
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    user-select: none;
}

/* 3D Viewport & Stage */
.cube-stage-container {
    height: 440px;
    min-height: 380px;
    background: radial-gradient(circle at center, var(--bs-tertiary-bg, #f1f5f9) 0%, var(--bs-body-bg, #e2e8f0) 100%);
    border-radius: 0;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    perspective: 1200px;
}

.cube-stage-container:active {
    cursor: grabbing;
}

.cube-viewport {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
}

.cube-scene {
    position: relative;
    width: 0;
    height: 0;
    transform-style: preserve-3d;
    transform: rotateX(-26deg) rotateY(38deg);
    transition: transform 0.05s ease-out;
}

/* Rotating Layer Pivot for Realistic 3D Move Animation */
.cube-pivot {
    position: absolute;
    width: 0;
    height: 0;
    left: 0;
    top: 0;
    transform-style: preserve-3d;
    pointer-events: none;
}

/* Custom Speed Slider */
.custom-speed-range {
    cursor: pointer;
    vertical-align: middle;
}

.custom-speed-range::-webkit-slider-thumb {
    background: #ffc107;
}

.custom-speed-range::-moz-range-thumb {
    background: #ffc107;
}

/* Individual Cubies */
.cubie {
    position: absolute;
    width: 68px;
    height: 68px;
    left: -34px;
    top: -34px;
    transform-style: preserve-3d;
    box-sizing: border-box;
}

.cubie-face {
    position: absolute;
    width: 68px;
    height: 68px;
    background-color: #141416;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    backface-visibility: hidden;
    border: 1px solid rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.6);
}

/* Face transforms */
.cubie-face.face-u { transform: rotateX(90deg) translateZ(34px); }
.cubie-face.face-d { transform: rotateX(-90deg) translateZ(34px); }
.cubie-face.face-f { transform: translateZ(34px); }
.cubie-face.face-b { transform: rotateY(180deg) translateZ(34px); }
.cubie-face.face-l { transform: rotateY(-90deg) translateZ(34px); }
.cubie-face.face-r { transform: rotateY(90deg) translateZ(34px); }

/* Stickers */
.sticker {
    width: 58px;
    height: 58px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.35), 0 1px 3px rgba(0, 0, 0, 0.4);
    transition: filter 0.15s ease, transform 0.15s ease;
    pointer-events: auto;
}

.paint-active .sticker:hover {
    filter: brightness(1.25);
    transform: scale(0.95);
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.9), inset 0 0 4px #fff;
}

/* Color Classes */
.color-w, .sticker-W { background-color: #ffffff !important; border: 1px solid #d1d5db; }
.color-y, .sticker-Y { background-color: #ffd600 !important; }
.color-g, .sticker-G { background-color: #00c853 !important; }
.color-b, .sticker-B { background-color: #2979ff !important; }
.color-o, .sticker-O { background-color: #ff6d00 !important; }
.color-r, .sticker-R { background-color: #d50000 !important; }
.color-k, .sticker-K { background-color: #1f2937 !important; }

/* Floating Face Indicator Labels */
.cube-face-labels {
    position: absolute;
    bottom: 12px;
    left: 12px;
    display: flex;
    gap: 6px;
    pointer-events: none;
    opacity: 0.85;
}

.cube-face-labels .badge {
    font-size: 0.72rem;
    backdrop-filter: blur(4px);
}

/* Color Swatches in Palette */
.color-swatch-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    padding: 0;
    border: 2px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

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

.color-swatch-btn.active {
    transform: scale(1.2);
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.4), 0 3px 6px rgba(0, 0, 0, 0.3);
}

/* 2D Unfolded Net Grid */
.cube-net-grid {
    display: grid;
    grid-template-columns: repeat(4, 66px);
    grid-template-rows: repeat(3, 66px);
    gap: 6px;
    padding: 4px;
}

.net-face {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    background-color: #18181b;
    padding: 3px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.net-face-u { grid-column: 2; grid-row: 1; }
.net-face-l { grid-column: 1; grid-row: 2; }
.net-face-f { grid-column: 2; grid-row: 2; }
.net-face-r { grid-column: 3; grid-row: 2; }
.net-face-b { grid-column: 4; grid-row: 2; }
.net-face-d { grid-column: 2; grid-row: 3; }

.net-sticker {
    border-radius: 3px;
    cursor: pointer;
    box-shadow: inset 0 0 2px rgba(255, 255, 255, 0.3);
    transition: transform 0.1s ease;
}

.net-sticker:hover {
    transform: scale(1.15);
    z-index: 2;
    box-shadow: 0 0 5px rgba(255, 193, 7, 0.9);
}

/* Solution Moves Strip */
.solution-moves-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
}

.move-chip {
    padding: 3px 8px;
    border-radius: 4px;
    background-color: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.move-chip:hover {
    background-color: var(--bs-primary-bg-subtle, #e0f2fe);
    border-color: var(--bs-primary, #0d6efd);
}

.move-chip.active {
    background-color: #ffc107 !important;
    color: #000 !important;
    border-color: #d39e00 !important;
    box-shadow: 0 0 6px rgba(255, 193, 7, 0.8);
    transform: scale(1.1);
}

.move-chip.done {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Speedcubing Timer */
.timer-display-box {
    transition: background-color 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    user-select: none;
}

.timer-armed {
    background-color: rgba(220, 53, 69, 0.15) !important;
    border-color: #dc3545 !important;
}

.timer-armed .timer-number {
    color: #dc3545 !important;
}

.timer-ready {
    background-color: rgba(25, 135, 84, 0.15) !important;
    border-color: #198754 !important;
}

.timer-ready .timer-number {
    color: #198754 !important;
}

.timer-running {
    background-color: rgba(13, 110, 253, 0.08) !important;
    border-color: #0d6efd !important;
}

.timer-running .timer-number {
    color: #0d6efd !important;
}

.timer-solves-list {
    max-height: 220px;
    overflow-y: auto;
}

/* Patterns Grid */
.patterns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.pattern-card {
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 8px;
    padding: 10px;
    background-color: var(--bs-body-bg, #fff);
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.pattern-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--bs-warning, #ffc107);
}

.pattern-icon {
    font-size: 1.6rem;
    color: var(--bs-warning, #ffc107);
    margin-bottom: 4px;
}

/* Mobile optimizations */
@media (max-width: 576px) {
    .cube-stage-container {
        height: 340px;
        min-height: 320px;
    }
    .cube-scene {
        width: 170px;
        height: 170px;
    }
    .cubie {
        width: 54px;
        height: 54px;
        left: 58px;
        top: 58px;
    }
    .cubie-face {
        width: 54px;
        height: 54px;
    }
    .cubie-face.face-u { transform: rotateX(90deg) translateZ(27px); }
    .cubie-face.face-d { transform: rotateX(-90deg) translateZ(27px); }
    .cubie-face.face-f { transform: translateZ(27px); }
    .cubie-face.face-b { transform: rotateY(180deg) translateZ(27px); }
    .cubie-face.face-l { transform: rotateY(-90deg) translateZ(27px); }
    .cubie-face.face-r { transform: rotateY(90deg) translateZ(27px); }
    .sticker {
        width: 46px;
        height: 46px;
    }
    .timer-number {
        font-size: 2.5rem !important;
    }
    .cube-net-grid {
        grid-template-columns: repeat(4, 52px);
        grid-template-rows: repeat(3, 52px);
    }
}
