/* ============================================
   RESET & BASE STYLES
   ============================================ */
   * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: clamp(14px, 3.5vw, 16px);
    line-height: 1.6;
    color: #222;
    background: #f5f5f5;
    background-attachment: fixed;
    min-height: 100dvh;
    overflow-x: hidden;
    position: relative;
}

/* ============================================
   SITE LOGO
   ============================================ */
.site-logo {
    width: fit-content;
    display: flex;
    justify-content: center;
    padding: 0;
}

.site-logo .logo-img {
    max-width: 116px;
    width: auto;
    height: auto;
    display: block;
    border-radius: 50%;
}

@media (min-width: 768px) {
    .site-logo {
        width: fit-content;
        justify-content: flex-start;
    }

    .site-logo .logo-img {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    }
}

.main-nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.main-nav a {
    color: #1f41a8;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.main-nav a:hover {
    text-decoration: underline;
}

.site-footer {
    margin-top: auto;
    padding: 24px 16px;
    text-align: center;
}

.site-footer a {
    color: #6b7280;
    text-decoration: none;
    font-size: 14px;
}

.site-footer a:hover {
    color: #1f41a8;
    text-decoration: underline;
}

/* ============================================
   MAIN CONTAINER & HERO CARD
   ============================================ */
main {
    position: relative;
    z-index: 5;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: max(env(safe-area-inset-top, 16px), 40px);
    gap: 24px;
}

.hero-card {
    width: 100%;
    max-width: 100%;
    padding: clamp(16px, 4vw, 24px);
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-card h1 {
    font-size: clamp(32px, 8vw, 56px);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #1f41a8;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: clamp(8px, 1.5vw, 12px);
    line-height: 1.1;
}

.hero-card .subtitle {
    font-size: clamp(14px, 3vw, 18px);
    color: #333;
    margin-bottom: 0;
    line-height: 1.4;
    font-weight: 500;
}

.flag-emoji {
    display: inline-block;
    margin: 0 4px;
    font-size: 1.1em;
    animation: wave 0.6s ease-in-out infinite;
}

@keyframes wave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(15deg);
    }
    75% {
        transform: rotate(-15deg);
    }
}

/* ============================================
   SEARCH CONTAINER & FIELD
   ============================================ */
.search-container {
    position: relative;
    width: 90%;
    max-width: 500px;
    margin: 0 auto;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.search-field {
    width: 100%;
    padding: 12px 16px 12px 45px;
    font-size: clamp(14px, 3vw, 16px);
    border: 2px solid rgba(31, 65, 168, 0.2);
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(31, 65, 168, 0.08);
    font-family: inherit;
    font-weight: 500;
}

.search-field:hover {
    border-color: rgba(31, 65, 168, 0.3);
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 6px 16px rgba(31, 65, 168, 0.12);
}

.search-field:focus {
    outline: none;
    border-color: #1f41a8;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 8px 24px rgba(31, 65, 168, 0.2);
}

.search-field::placeholder {
    color: rgba(51, 51, 51, 0.5);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    pointer-events: none;
    color: #1f41a8;
    opacity: 0.7;
}

.search-field:focus ~ .search-icon {
    opacity: 1;
    animation: searchPulse 0.6s ease;
}

@keyframes searchPulse {
    0% {
        transform: translateY(-50%) scale(1);
    }
    50% {
        transform: translateY(-50%) scale(1.2);
    }
    100% {
        transform: translateY(-50%) scale(1);
    }
}

/* ============================================
   BADGE BOX CONTAINER
   ============================================ */
.badge-box {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    gap: 1px;
    padding: 16px;
    max-width: 100%;
    margin: 16px auto;
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ============================================
   SCROLLBAR STYLING (Webkit browsers)
   ============================================ */
.badge-box::-webkit-scrollbar {
    width: 8px;
}

.badge-box::-webkit-scrollbar-track {
    background: rgba(31, 65, 168, 0.08);
    border-radius: 10px;
}

.badge-box::-webkit-scrollbar-thumb {
    background: rgba(31, 65, 168, 0.4);
    border-radius: 10px;
}

.badge-box::-webkit-scrollbar-thumb:hover {
    background: rgba(31, 65, 168, 0.6);
}

/* ============================================
   BADGE LAYER (left-to-right, flow down)
   ============================================ */
#badge-layer {
    display: contents;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.92);
    border: 1.5px solid rgba(31, 65, 168, 0.2);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: clamp(11px, 2.5vw, 13px);
    font-weight: 600;
    color: #1f41a8;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    white-space: nowrap;
    user-select: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.badge:hover {
    box-shadow: 0 4px 16px rgba(31, 65, 168, 0.15);
    border-color: rgba(31, 65, 168, 0.4);
}

.badge-img {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.badge-placeholder {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #138808;
    flex-shrink: 0;
}

.user-card {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    contain: layout style;
    content-visibility: auto;
    min-height: 68px;
}

.user-image {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e5e7eb;
    display: block;
}

.user-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    font-size: 24px;
    font-weight: 600;
    color: #4f46e5;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    margin: 0;
    word-break: break-word;
}

.user-card.highlighted .user-image {
    border: 2px solid #e1306c;
    box-shadow: 0 0 0 2px #405de6, 0 0 12px rgba(225, 48, 108, 0.5);
    animation: instagramZoom 0.4s ease-out;
}

@keyframes instagramZoom {
    0% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ============================================
   HIGHLIGHT MATCHING BADGES
   ============================================ */
.badge.hidden {
    opacity: 0.15;
    pointer-events: none;
}

.badge.matched {
    background: rgba(31, 65, 168, 0.12) !important;
    border-color: #1f41a8 !important;
    box-shadow: 0 4px 20px rgba(31, 65, 168, 0.25) !important;
}

/* ============================================
   RESPONSIVE: MOBILE
   ============================================ */
@media (min-width: 480px) {
    .search-container {
        width: 85%;
        max-width: 500px;
    }

    .search-field {
        padding: 13px 16px 13px 45px;
    }
}

/* ============================================
   RESPONSIVE: TABLET
   ============================================ */
@media (min-width: 768px) {
    body {
        font-size: 16px;
    }

    main {
        gap: 28px;
    }

    .hero-card h1 {
        font-size: 48px;
        margin-bottom: 20px;
    }

    .hero-card .subtitle {
        font-size: 16px;
        margin-bottom: 24px;
    }

    .search-container {
        width: 85%;
        max-width: 550px;
        margin: 0 auto 8px;
    }

    .search-field {
        padding: 14px 18px 14px 48px;
        font-size: 16px;
    }

    .search-icon {
        left: 16px;
        font-size: 20px;
    }

    .badge-box {
        min-height: 550px;
        max-height: 75vh;
    }

    .badge {
        font-size: 13px;
        padding: 8px 14px;
        border-width: 1.5px;
    }
}

/* ============================================
   RESPONSIVE: DESKTOP
   ============================================ */
@media (min-width: 1024px) {
    .hero-card h1 {
        font-size: 52px;
    }

    .search-container {
        width: 80%;
        max-width: 600px;
    }

    .search-field {
        padding: 15px 20px 15px 50px;
        font-size: 16px;
    }

    .search-icon {
        left: 18px;
        font-size: 20px;
    }

    .badge-box {
        min-height: 600px;
        max-height: 80vh;
    }

    .badge {
        font-size: 13px;
        padding: 8px 14px;
    }

    .badge:hover {
        box-shadow: 0 6px 24px rgba(31, 65, 168, 0.2) !important;
    }
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .badge,
    .search-field,
    .hero-card,
    .flag-emoji {
        animation: none !important;
        transition: none !important;
    }

    .badge:hover {
        transform: none;
    }
    .instagram-link {
    margin-left: 15px;
    padding: 8px 14px;
    background: #E1306C;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: 0.2s ease;
}

.instagram-link:hover {
    background: #c72c5d;
}