:root {
    --primary-color: #00ff41;
    /* Matrix Green */
    --secondary-color: #008F11;
    /* Darker Green */
    --accent-color: #003B00;
    /* Very Dark Green */
    --bg-color: #0d0d0d;
    --text-color: #e0e0e0;
    --alert-color: #ff0055;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #000;
    color: var(--primary-color);
    font-family: 'Share Tech Mono', monospace;
    margin: 0;
    min-height: 100vh;
    /* Use min-height to allow growth */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    /* Allow vertical scrolling */
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    position: relative;
}

.container {
    width: 90%;
    max-width: 800px;
    text-align: center;
    z-index: 2;
    padding: 20px 0;
    /* Add vertical padding */
    margin: auto;
    /* Center vertically if possible, but allow scroll */
}

/* CRT Scanline Effect */
.scan-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0),
            rgba(255, 255, 255, 0) 50%,
            rgba(0, 0, 0, 0.2) 50%,
            rgba(0, 0, 0, 0.2));
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 10;
}

header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 10px;
}

h1 {
    font-size: 2rem;
    text-shadow: 0 0 10px var(--primary-color);
    margin-bottom: 10px;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--secondary-color);
}

.blink {
    animation: blink-animation 1s steps(2, start) infinite;
}

@keyframes blink-animation {
    to {
        visibility: hidden;
    }
}

/* Scanner Section */
.scanner-frame {
    width: 100%;
    /* Force a 16:9 aspect ratio so the map and stamps scale together perfectly */
    aspect-ratio: 16 / 9;
    height: auto;
    /* Remove fixed height */
    border: 1px solid var(--secondary-color);
    position: relative;
    margin-bottom: 20px;
    background: rgba(0, 59, 0, 0.2);
    overflow: hidden;
}

.grid-lines {
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(var(--secondary-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--secondary-color) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: center;
    opacity: 0.2;
    position: absolute;
    z-index: 1;
}

.map-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.world-map {
    width: 100%;
    height: 100%;
    /* 'fill' stretches it to match the container (which is 16:9). 
       If the image isn't 16:9, it might stretch slightly, but stamps will stay aligned. */
    object-fit: fill;
    opacity: 0.6;
    transition: transform 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: 70% 45%;
    /* Approximate location of India */
}

/* Zoom Levels */
.world-map.zoom-india {
    transform: scale(3);
}

.world-map.zoom-trichy {
    transform: scale(8);
}

/* Stamps - Percentages are now relative to the 16:9 container */
.stamp {
    position: absolute;
    font-size: clamp(0.6rem, 2vw, 1rem);
    /* Responsive font size */
    font-weight: bold;
    border: 2px solid;
    padding: 2px 5px;
    transform: translate(-50%, -50%) rotate(-15deg) scale(2);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    white-space: nowrap;
}

.stamp.visible {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-15deg) scale(1);
}

/* Adjusted coordinates for a standard world map projection */
.stamp-na {
    top: 25%;
    left: 20%;
    color: var(--alert-color);
    border-color: var(--alert-color);
}

/* North America */
.stamp-sa {
    top: 65%;
    left: 28%;
    color: var(--alert-color);
    border-color: var(--alert-color);
}

/* South America */
.stamp-eu {
    top: 25%;
    left: 52%;
    color: var(--alert-color);
    border-color: var(--alert-color);
}

/* Europe */
.stamp-af {
    top: 55%;
    left: 53%;
    color: var(--alert-color);
    border-color: var(--alert-color);
}

/* Africa */
.stamp-as {
    top: 45%;
    left: 68%;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Asia (India) */

/* Location Pin (Target Style) */
.map-pin {
    position: absolute;
    /* Adjusted for Trichy (South India) - Moved Left to 50% */
    top: 42%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid var(--alert-color);
    border-radius: 50% 50% 50% 0;
    /* Teardrop shape for pin */
    background: rgba(255, 0, 85, 0.5);
    box-shadow: 0 0 10px var(--alert-color);
    transform: translate(-50%, -50%) rotate(-45deg) scale(0);
    /* Hidden initially */
    z-index: 10;
}

.map-pin::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: var(--alert-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.map-pin.visible {
    /* Remove scale(0) so it can animate */
    transform: translate(-50%, -50%) rotate(-45deg) scale(1);
    animation: drop-pin 0.8s cubic-bezier(0.36, 0, 0.66, -0.56) forwards;
    /* Bouncy */
}

@keyframes drop-pin {
    0% {
        opacity: 0;
        transform: translate(-50%, -300%) rotate(-45deg);
    }

    60% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(-45deg);
    }

    75% {
        transform: translate(-50%, -70%) rotate(-45deg);
    }

    90% {
        transform: translate(-50%, -50%) rotate(-45deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(-45deg);
    }
}

.radar-sweep {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-color);
    animation: scan-down 2s linear infinite;
}

@keyframes scan-down {
    0% {
        top: -5%;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 105%;
        opacity: 0;
    }
}

.controls {
    text-align: center;
    margin-bottom: 20px;
}

.instruction {
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.cyber-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 15px 40px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.2rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.cyber-btn:hover {
    background: var(--primary-color);
    color: var(--bg-color);
    box-shadow: 0 0 20px var(--primary-color);
}

.log-terminal {
    height: 150px;
    background: #000;
    border: 1px solid var(--secondary-color);
    padding: 10px;
    font-size: 0.9rem;
    overflow-y: auto;
    text-align: left;
}

.log-entry {
    margin-bottom: 5px;
    display: block;
}

/* Result Section */
.hidden {
    display: none;
}

.match-container {
    text-align: center;
    animation: fade-in 2s ease-out;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.match-header {
    color: var(--alert-color);
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-shadow: 0 0 10px var(--alert-color);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.image-frame {
    position: relative;
    width: 300px;
    height: 300px;
    /* Square for now */
    margin: 0 auto 20px;
    border: 2px solid var(--alert-color);
    padding: 10px;
    box-shadow: 0 0 30px rgba(255, 0, 85, 0.3);
}

#result-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#result-image.enhanced {
    filter: sepia(0%) hue-rotate(0deg) saturate(100%) brightness(1.1) contrast(1);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
}

.match-overlay {
    position: absolute;
    bottom: 20px;
    right: -20px;
    background: var(--alert-color);
    color: white;
    padding: 5px 15px;
    font-weight: bold;
    transform: rotate(-5deg);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
    z-index: 5;
}

/* Heart Explosion */
.floating-heart {
    position: absolute;
    width: 20px;
    /* Smaller hearts */
    height: 20px;
    pointer-events: none;
    transform: translate(-50%, -50%);
    /* Center anchor */
    animation: burst-out ease-out forwards;
    z-index: 20;
}

@keyframes burst-out {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    100% {
        /* Move outward to calculated offsets */
        transform: translate(calc(-50% + var(--tx)),
                calc(-50% + var(--ty))) scale(1.2);
        opacity: 0;
    }
}

.analysis-report {
    border: 1px solid var(--primary-color);
    padding: 20px;
    background: rgba(0, 255, 65, 0.05);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    border-bottom: 1px dashed var(--secondary-color);
    padding-bottom: 5px;
}

.stat-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.highlight {
    color: var(--alert-color);
    font-weight: bold;
    text-shadow: 0 0 5px var(--alert-color);
}

/* Responsive */
@media (max-width: 600px) {
    h1 {
        font-size: 1.5rem;
    }

    .image-frame {
        width: 100%;
        height: auto;
        aspect-ratio: 1/1;
    }
}
