/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-cyan: #00d4ff;
    --primary-blue: #0066ff;
    --dark-bg: #0a0e27;
    --darker-bg: #050812;
    --card-bg: rgba(15, 23, 42, 0.7);
    --border-color: rgba(0, 212, 255, 0.3);
    --selected-glow: rgba(0, 212, 255, 0.6);
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #0d1f3c;
    background-image: url('background.png');
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Container */
.container {
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    z-index: 1;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding: 1.5rem 2rem;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Header styling update */
.logo {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.time-series-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.circle-icon {
    width: 24px;
    height: 24px;
    border: 2px solid var(--primary-cyan);
    border-radius: 50%;
    position: relative;
}

.circle-icon.filled {
    background: var(--primary-cyan);
    opacity: 0.5;
}

.arrow-icon-small {
    color: var(--text-primary);
    font-size: 1.2rem;
}

.logo-text h1 {
    font-size: 2.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #fff, #a0aec0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

/* Action button */
.action-btn {
    padding: 0.875rem 2.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(0, 212, 255, 0.6);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Image grid - Force 2 rows (5 columns for 10 items) */
.image-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2rem;
    /* More space */
    padding: 2rem 0;
    animation: fadeIn 0.5s ease-in;
    max-width: 1600px;
    margin: 0 auto;
}

/* Responsive adjustment for grid */
@media (max-width: 1200px) {
    .image-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 900px) {
    .image-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.image-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
}

.image-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    object-position: center 60%;
    display: block;
    transition: transform 0.4s ease;
}

.image-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0, 212, 255, 0.3);
}

/* Numbered badge on selected images */
.image-card .number-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    animation: badgePop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.image-card .number-badge.red {
    background: linear-gradient(135deg, #ff4444, #cc0000);
}

.image-card .number-badge.blue {
    background: linear-gradient(135deg, #4444ff, #0000cc);
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

.image-card:hover img {
    transform: scale(1.05);
}

/* Selection mode active */
.selection-mode .image-card {
    cursor: pointer;
}

/* Selected state */
.image-card.selected {
    border-color: var(--primary-cyan);
    box-shadow: 0 0 30px var(--selected-glow),
        inset 0 0 20px rgba(0, 212, 255, 0.1);
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 30px var(--selected-glow),
            inset 0 0 20px rgba(0, 212, 255, 0.1);
    }

    50% {
        box-shadow: 0 0 50px var(--selected-glow),
            inset 0 0 30px rgba(0, 212, 255, 0.2);
    }
}

/* Hidden state */
.hidden {
    display: none !important;
}

/* Comparison view - Two pairs layout */
.comparison-view {
    animation: fadeIn 0.5s ease-in;
}

.pairs-container {
    display: flex;
    gap: 3rem;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.pair-wrapper {
    flex: 1 1 0;
    width: 100%;
    max-width: 600px;
    min-width: 400px;
    cursor: default;
    transition: all 0.3s ease;
}

.pair-wrapper.dragging {
    opacity: 1;
    transform: none;
}

.pair-wrapper.drag-over {
    transform: none;
}

.pair-content {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem;
    border: 2px solid var(--border-color);
}

.pair-images {
    display: flex;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.pair-image-card {
    flex: 1 1 0;
    min-width: 0;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid var(--primary-cyan);
    box-shadow: 0 0 30px var(--selected-glow);
    background: var(--card-bg);
    cursor: move;
    transition: all 0.3s ease;
    position: relative;
}

.pair-image-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.pair-image-card.drag-over {
    border-color: #00ff00;
    box-shadow: 0 0 50px rgba(0, 255, 0, 0.6);
}

/* Touch/tap selection for swap */
.pair-image-card.selected-for-swap {
    border-color: #ffcc00;
    box-shadow: 0 0 40px rgba(255, 204, 0, 0.8);
    transform: scale(1.02);
}

/* Swap animation feedback */
.pair-image-card.swapped {
    animation: swapPulse 0.3s ease-out;
}

@keyframes swapPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 60px rgba(0, 255, 0, 0.8);
    }

    100% {
        transform: scale(1);
    }
}

.pair-image-card img {
    width: 100%;
    height: 300px;
    display: block;
    object-fit: cover;
    pointer-events: none;
}

/* Arrow between images */
.arrow-container {
    flex-shrink: 0;
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.arrow-icon {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 212, 255, 0.5));
}

/* Dropdown wrapper */
.dropdown-wrapper {
    padding: 1.5rem;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.dropdown-wrapper label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.category-select {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: rgba(10, 14, 39, 0.8);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.category-select:hover {
    border-color: var(--primary-cyan);
}

.category-select:focus {
    border-color: var(--primary-cyan);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.category-select option {
    background: var(--dark-bg);
    color: var(--text-primary);
    padding: 0.5rem;
}

.category-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tablet optimization (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        padding: 1.5rem;
        max-width: 100%;
    }

    header {
        padding: 1.25rem 1.75rem;
    }

    .logo-image {
        height: 70px;
    }

    .action-btn {
        padding: 1rem 3rem;
        font-size: 1.125rem;
        min-height: 50px;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 2rem;
    }

    .image-card {
        border-width: 3px;
    }

    .image-card img {
        height: 280px;
    }

    .number-badge {
        width: 55px;
        height: 55px;
        font-size: 1.75rem;
        top: 20px;
        right: 20px;
    }

    .pairs-container {
        gap: 2.5rem;
    }

    .pair-wrapper {
        min-width: 450px;
    }

    .pair-image-card img {
        max-height: 350px;
    }

    .category-select {
        padding: 1.25rem;
        font-size: 1.125rem;
        min-height: 55px;
    }

    .dropdown-wrapper label {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
}

/* Mobile design */
@media (max-width: 767px) {
    .container {
        padding: 1rem;
    }

    header {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }

    .logo {
        justify-content: center;
    }

    .logo-image {
        height: 60px;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }

    .pairs-container {
        flex-direction: column;
        gap: 2rem;
    }

    .pair-wrapper {
        min-width: 100%;
    }

    .action-btn {
        padding: 0.875rem 2.5rem;
        font-size: 1rem;
    }
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-in;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 2px solid var(--border-color);
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 212, 255, 0.3);
    animation: slideUp 0.3s ease-out;
}

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

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--primary-cyan);
    color: white;
    font-size: 2rem;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
    line-height: 1;
}

.modal-close:hover {
    background: var(--primary-cyan);
    transform: rotate(90deg);
}

.modal-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    color: var(--primary-cyan);
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-body {
    padding: 2rem;
    max-height: calc(85vh - 120px);
    overflow-y: auto;
}

.modal-body img {
    width: 100%;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    border: 2px solid var(--border-color);
}

.modal-info {
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-info p {
    margin-bottom: 1rem;
}

/* Locked state (after final confirmation) */
.locked .image-card,
.locked .category-select {
    pointer-events: none;
    opacity: 0.9;
}

.locked .action-btn {
    background: linear-gradient(135deg, #666, #888);
    box-shadow: none;
}

.locked .category-select {
    pointer-events: none;
    opacity: 0.9;
}


/* Result Overlay */
#resultOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(5, 8, 18, 0.95);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    animation: fadeIn 0.5s ease-in;
}

.shape-container {
    width: 300px;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Success Cross */
.shape-cross {
    position: relative;
    width: 200px;
    height: 200px;
}

.shape-cross::before,
.shape-cross::after {
    content: '';
    position: absolute;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.shape-cross::before {
    top: 50%;
    left: 0;
    width: 100%;
    height: 40px;
    transform: translateY(-50%);
}

.shape-cross::after {
    left: 50%;
    top: 0;
    height: 100%;
    width: 40px;
    transform: translateX(-50%);
}

/* Failure Shapes */
.shape-triangle {
    width: 0;
    height: 0;
    border-left: 120px solid transparent;
    border-right: 120px solid transparent;
    border-bottom: 200px solid #ff4444;
    filter: drop-shadow(0 0 15px rgba(255, 68, 68, 0.6));
}

.shape-circle {
    width: 200px;
    height: 200px;
    background-color: #ffbb33;
    border-radius: 50%;
    box-shadow: 0 0 30px rgba(255, 187, 51, 0.6);
}

.shape-x:before,
.shape-x:after {
    content: '';
    position: absolute;
    width: 250px;
    height: 40px;
    background-color: #ff4444;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

.shape-x:before {
    transform: rotate(45deg);
}

.shape-x:after {
    transform: rotate(-45deg);
}

.shape-x {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 200px;
    height: 200px;
}