.cube-animation {
    --cube-cell: 28px;
    --cube-face: calc(var(--cube-cell) * 4);
    --fold-speed: 1500ms;
    margin: 20px auto 14px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: radial-gradient(circle at 50% 38%, rgba(255, 210, 63, 0.08), transparent 48%), #090b10;
}

.cube-stage {
    position: relative;
    display: grid;
    width: 100%;
    height: 470px;
    perspective: 1200px;
    place-items: center;
    touch-action: pan-y;
}

.cube-wrapper {
    position: relative;
    width: var(--cube-face);
    height: var(--cube-face);
    cursor: grab;
    transform-style: preserve-3d;
    transition: transform var(--fold-speed) cubic-bezier(.62, .04, .28, 1);
}

.cube-wrapper.dragging {
    cursor: grabbing;
    transition: none;
}

.cube-face {
    position: absolute;
    inset: 0;
    width: var(--cube-face);
    height: var(--cube-face);
    transform-style: preserve-3d;
    transition: transform var(--fold-speed) cubic-bezier(.62, .04, .28, 1);
}

.cube-grid {
    display: grid;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border: 1px solid rgba(182, 189, 204, 0.45);
    border-radius: 3px;
    background: linear-gradient(155deg, #151a24, #0b0e14);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.46);
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.cube-cell {
    display: grid;
    min-width: 0;
    border: 1px solid rgba(182, 189, 204, 0.18);
    color: #f7f8fb;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    place-items: center;
    user-select: none;
}

.cube-cell.candidates {
    padding: 1px;
    color: #9ca6b8;
    font-size: 5.5px;
    line-height: 1.1;
    text-align: center;
}

.cube-cell.empty {
    color: transparent;
}

.cube-cell.pin {
    background: rgba(255, 210, 63, 0.82);
    color: #151200;
}

.cube-cell.dimension-vertical {
    background: #1769c2;
    color: #fff;
}

.cube-cell.dimension-horizontal {
    background: #198754;
    color: #fff;
}

.cube-cell.dimension-lateral {
    background: #c43d43;
    color: #fff;
}

.cube-cell.dimension-vertical.dimension-horizontal {
    background: linear-gradient(135deg, #1769c2 0 50%, #198754 50% 100%);
}

.cube-cell.dimension-vertical.dimension-lateral {
    background: linear-gradient(135deg, #1769c2 0 50%, #c43d43 50% 100%);
}

.cube-cell.dimension-horizontal.dimension-lateral {
    background: linear-gradient(135deg, #198754 0 50%, #c43d43 50% 100%);
}

.cube-label {
    position: absolute;
    top: 3px;
    left: 4px;
    z-index: 1;
    color: rgba(247, 248, 251, 0.58);
    font-size: 6px;
    font-weight: 800;
    letter-spacing: 0;
    pointer-events: none;
}

.cube-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    padding: 0 14px 15px;
}

.cube-control-button {
    padding: 9px 14px;
    border: 1px solid rgba(255, 210, 63, 0.55);
    border-radius: 6px;
    background: rgba(255, 210, 63, 0.08);
    color: var(--accent-soft);
    cursor: pointer;
    font: 700 0.75rem/1 "Segoe UI", Candara, sans-serif;
}

.cube-control-button:hover,
.cube-control-button:focus-visible {
    border-color: var(--accent);
    background: rgba(255, 210, 63, 0.14);
}

.cube-speed {
    display: flex;
    flex-basis: 100%;
    gap: 10px;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.72rem;
}

.cube-speed input {
    width: min(190px, 55%);
    accent-color: var(--accent);
}

.cube-speed-output {
    min-width: 42px;
    color: var(--accent-soft);
    font-weight: 700;
    text-align: right;
}

.cube-dimension-legend {
    display: flex;
    flex-basis: 100%;
    flex-wrap: wrap;
    gap: 8px 14px;
    justify-content: center;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.7rem;
}

.cube-dimension-legend span {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.cube-dimension-legend i {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

@media (max-width: 480px) {
    .cube-animation {
        --cube-cell: 23px;
    }

    .cube-stage {
        height: 390px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cube-wrapper,
    .cube-face {
        transition-duration: 1ms;
    }
}
