/* Captcha Container */
.puzzle-captcha {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    width: 304px;
    user-select: none;
}

/* Header */
.captcha-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.captcha-header-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}

.refresh-button {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.refresh-button:hover {
    color: #111827;
    background: #f3f4f6;
}

.refresh-button svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* Puzzle Canvas */
.puzzle-canvas {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    width: 280px;
    height: 150px;
    background-color: #d1d5db;
}

.puzzle-canvas.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.puzzle-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Target Hole */
.target-hole {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
    clip-path: path('M4,0 H32 a4,4 0 0 1 4,4 V16 a7,7 0 0 1 0,14 V42 a4,4 0 0 1 -4,4 H4 a4,4 0 0 1 -4,-4 V4 a4,4 0 0 1 4,-4 Z');
    background-color: rgba(10, 15, 25, 0.45);
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.8);
    pointer-events: none;
}

/* Draggable Piece */
.draggable-piece {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
    clip-path: path('M4,0 H32 a4,4 0 0 1 4,4 V16 a7,7 0 0 1 0,14 V42 a4,4 0 0 1 -4,4 H4 a4,4 0 0 1 -4,-4 V4 a4,4 0 0 1 4,-4 Z');
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.9);
    cursor: grab;
    background-image: url('/images/login.jpg');
    background-size: 280px 150px;
    background-position: 0px 0px;
    z-index: 2;
}

.draggable-piece.verified {
    box-shadow: inset 0 0 0 2px #22c55e;
    cursor: default;
}

.draggable-piece:active {
    cursor: grabbing;
}

/* Verified Overlay */
.verified-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    z-index: 3;
    pointer-events: none;
}

.verified-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 9999px;
    background: #22c55e;
    color: white;
    padding: 4px 12px;
    font-size: 0.875rem;
    font-weight: 600;
}

.verified-badge svg {
    width: 16px;
    height: 16px;
}

/* Track */
.track {
    position: relative;
    height: 36px;
    width: 280px;
    border-radius: 6px;
    background: #f3f4f6;
}

.track-progress {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.2);
    pointer-events: none;
    transition: width 0.05s linear;
}

.track-handle {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    width: 36px;
    height: 36px;
    cursor: grab;
    color: #6b7280;
    z-index: 4;
}

.track-handle:active {
    cursor: grabbing;
}

.track-handle.verified {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

.track-handle svg {
    width: 16px;
    height: 16px;
}

.track-handle.verified svg {
    width: 16px;
    height: 16px;
}

.track-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #6b7280;
    pointer-events: none;
}

/* Result Display */
#captcha-result {
    margin-top: 16px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #374151;
    min-height: 40px;
}

/* Responsive */
@media (max-width: 350px) {
    .puzzle-captcha {
        width: 100%;
        padding: 8px;
    }
    .puzzle-canvas,
    .track {
        width: 100%;
    }
    .puzzle-canvas {
        height: auto;
        aspect-ratio: 280/150;
    }
}