:root {
    --primary-color: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --bg-color: #0f172a;
    /* Slate 900 */
    --card-bg: #1e293b;
    /* Slate 800 */
    --text-color: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --border-color: #334155;
    /* Slate 700 */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --accent-color: #10b981;
    /* Emerald 500 */
    --menu-bg: rgba(15, 23, 42, 0.95);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

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

html {
    overflow-y: scroll;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    padding-top: 6rem;
    /* Space for fixed header */
    line-height: 1.5;
    overflow-x: hidden;
}

/* --- Navigation Menu --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--menu-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-color);
    text-decoration: none;
    letter-spacing: 1px;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    font-size: 0.95rem;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
}

.hamburger {
    display: none;
    flex-direction: column;
    width: 24px;
    height: 18px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    z-index: 1200;
    position: relative;
    /* Above overlay */
}

.bar {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-color);
    transition: all 0.3s ease;
    border-radius: 2px;
    position: absolute;
    left: 0;
}

.bar:nth-child(1) {
    top: 0;
}

.bar:nth-child(2) {
    top: 50%;
    transform: translateY(-50%);
}

.bar:nth-child(3) {
    bottom: 0;
}

/* Burger Animation State */
body.menu-open .hamburger .bar:nth-child(1) {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

body.menu-open .hamburger .bar:nth-child(2) {
    opacity: 0;
}

body.menu-open .hamburger .bar:nth-child(3) {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%) rotate(-45deg);
}

/* Mobile Nav Overlay */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(15, 23, 42, 0.98);
    /* Deep dark blue to match theme */
    z-index: 900;
    /* Below Navbar (1000) so Title is visible */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    backdrop-filter: blur(5px);
}

.mobile-nav-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.mobile-nav-overlay ul {
    list-style: none;
    text-align: center;
    gap: 40px;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
}

.mobile-nav-overlay a {
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s;
}

.mobile-nav-overlay a:hover,
.mobile-nav-overlay a.active {
    color: var(--primary-color);
}

@media (max-width: 855px) {
    .hamburger {
        display: flex;
    }

    /* Hide desktop links on mobile */
    .nav-links {
        display: none;
    }
}

/* --- Common UI --- */
header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #9fa7f6;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: -1px;
}

p.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

main {
    width: 100%;
    max-width: 1200px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

@media (min-width: 1024px) {
    main.three-col {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .results-container {
        grid-column: 1 / -1;
    }
}

.input-group {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.input-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

label {
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #e2e8f0;
}

textarea {
    width: 100%;
    height: 200px;
    background-color: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-color);
    padding: 1rem;
    font-family: inherit;
    font-size: 16px;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

button.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

button.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary {
    background-color: transparent !important;
    color: white !important;
    border: 2px solid var(--primary-color) !important;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background-color: rgba(99, 102, 241, 0.2) !important;
    transform: translateY(-2px);
}

/* Results Section */
.results-container {
    margin-top: 2rem;
    display: none;
    animation: fadeIn 0.5s ease-in-out;
    width: 100%;
}

.results-container.show {
    display: block;
}

.results-header {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.pairs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.pair-card {
    background-color: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
    position: relative;
    overflow: hidden;
}

/* Decorative border left */
.pair-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, var(--primary-color), var(--accent-color));
}

.person-name {
    font-weight: 700;
    font-size: 1.2rem;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
}

.color-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(99, 102, 241, 0.15);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.dish-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(16, 185, 129, 0.15);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

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

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

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

/* Loader */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Sample Placeholders */
::placeholder {
    color: #475569;
}

/* --- Custom Layout & Modal Styles --- */

/* Custom layout override for index.html (and potentially others) */
main.custom-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 600px;
    /* Constrain width for better look */
    margin: 0 auto;
}

/* Centered dropdown text */
select#winner-count {
    text-align: center;
    text-align-last: center;
}

/* Custom Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.custom-modal {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    width: 400px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.show .custom-modal {
    transform: scale(1);
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.modal-message {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.modal-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-btn:hover {
    background-color: var(--primary-hover);
}

/* --- AdSense Placeholder --- */
.ad-banner-placeholder {
    width: 100%;
    max-width: 728px;
    /* Leaderboard size */
    height: 90px;
    background-color: #ffffff;
    margin: 4rem auto 2rem auto;
    /* Spacing from content and bottom */
    display: flex;
    justify-content: center;
    align-items: center;
    color: #cbd5e1;
    /* Light gray text */
    font-size: 0.9rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .ad-banner-placeholder {
        max-width: 320px;
        /* Mobile banner */
        height: 100px;
    }
}

/* --- Footer --- */
.site-footer {
    width: 100%;
    margin-top: auto;
    padding: 1.2rem 1rem;
    /* Reduced from 1.5rem */
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    /* Reduced from 1rem */
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    /* Reduced from 2rem */
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-link {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
    /* Slight reduction */
    font-weight: 500;
    transition: color 0.2s ease, transform 0.2s ease;
    padding: 0.2rem 0;
    /* Reduced */
    position: relative;
    opacity: 0.9;
}

.footer-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 50%;
    background-color: var(--primary-color);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.footer-link:hover {
    color: var(--primary-color);
    opacity: 1;
}

.footer-link:hover::after {
    width: 100%;
}

.footer-legal {
    font-size: 0.7rem;
    /* Slight reduction */
    color: var(--text-muted);
    opacity: 0.6;
    margin-top: 0.2rem;
    /* Reduced from 1rem */
}

@media (max-width: 600px) {
    .site-footer {
        padding: 1rem 0.5rem;
        /* Reduced further for mobile */
    }

    .footer-links {
        flex-direction: column;
        gap: 0.25rem;
        /* Tighter vertical stacking on mobile */
        width: 100%;
    }

    .footer-link {
        display: block;
        padding: 0.2rem;
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .footer-link:last-child {
        border-bottom: none;
    }

    .footer-link::after {
        display: none;
        /* No underline anim on mobile, clearer stacking */
    }
}