:root {
    --primary-color: #2b6cb0;
    --bg-color: #f7fafc;
    --card-bg: rgba(255, 255, 255, 0.45);
    --text-color: #2d3748;
    --muted-color: #718096;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
}

img.emoji {
   height: 1em;
   width: 1em;
   margin: 0 .05em 0 .1em;
   vertical-align: -0.1em;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden; /* Prevent scrolling, keep it app-like */
}

.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    padding: 1rem;
    z-index: 100;
    background: linear-gradient(to bottom, rgba(247,250,252,1) 0%, rgba(247,250,252,0) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    position: relative;
}

.menu-container {
    position: relative;
}

#menu-btn {
    background: white;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 1.5rem;
    padding: 6px 12px;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.2s;
}

#menu-btn:hover {
    background: #edf2f7;
}

#nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    min-width: 200px;
    overflow: hidden;
    z-index: 200;
}

#nav-menu.hidden {
    display: none;
}

#nav-menu a {
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: background 0.2s;
    text-align: left;
}

#nav-menu a:hover {
    background: #edf2f7;
    color: var(--primary-color);
}

#search-input {
    width: 100%;
    max-width: 400px;
    padding: 12px 20px;
    border-radius: 25px;
    border: 2px solid #cbd5e0;
    font-size: 1rem;
    outline: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

#search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(43, 108, 176, 0.2);
}

.main-content {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flags-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 2rem;
    padding-bottom: 300px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    gap: 20px;
    overflow-y: auto;
    z-index: 1;
}

.flag-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    width: 80px;
    opacity: 0.8;
}

.flag-item:hover {
    transform: scale(1.1);
    opacity: 1;
}

.flag-item.disabled {
    opacity: 0.2;
    pointer-events: none;
}

.flag-emoji {
    font-size: 3rem;
    line-height: 1;
}

.flag-name {
    font-size: 0.75rem;
    text-align: center;
    margin-top: 5px;
    font-weight: 600;
}

.central-card {
    position: relative;
    z-index: 10;
    background: var(--card-bg);
    padding: 3rem 2rem;
    border-radius: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 700px;
    width: 90%;
    text-align: center;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.4s ease;
}

h1 {
    font-size: 1.5rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.muted {
    color: var(--muted-color);
    font-weight: 400;
}

.slot {
    display: inline-block;
    padding: 5px 15px;
    border-bottom: 2px dashed #cbd5e0;
    color: var(--primary-color);
    transition: all 0.3s ease;
}

.slot.filled {
    border-bottom: 2px solid var(--primary-color);
    background: rgba(43, 108, 176, 0.1);
    border-radius: 8px;
}

#status-message {
    color: var(--muted-color);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    height: 20px;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-weight: 600;
    transition: all 0.2s;
}

#go-btn {
    background: var(--primary-color);
    color: white;
    padding: 12px 30px;
    font-size: 1.1rem;
    border-radius: 25px;
    box-shadow: 0 4px 6px rgba(43, 108, 176, 0.3);
}

#go-btn:hover {
    background: #2c5282;
    transform: translateY(-2px);
}

.text-btn {
    background: transparent;
    color: var(--muted-color);
    margin-left: 10px;
    font-size: 0.9rem;
}

.text-btn:hover {
    color: var(--text-color);
    text-decoration: underline;
}

.mt-2 { margin-top: 1rem; }

.hidden {
    display: none !important;
}

/* Result Phase */
.ready-message {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 2rem;
    color: var(--text-color);
    line-height: 1.6;
}

textarea {
    width: 100%;
    height: 250px;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #cbd5e0;
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.7);
}

.ai-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.ai-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 20px;
    background: white;
    border: 1px solid #e2e8f0;
    color: var(--text-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.ai-btn:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

.ai-icon {
    width: 20px;
    height: 20px;
}

/* Custom Scrollbar for flags container */
.flags-grid::-webkit-scrollbar {
    width: 8px;
}
.flags-grid::-webkit-scrollbar-track {
    background: transparent;
}
.flags-grid::-webkit-scrollbar-thumb {
    background-color: #cbd5e0;
    border-radius: 4px;
}

/* Mobile Responsiveness & Small Screens */
@media (max-width: 900px), (max-height: 700px) {
    .central-card {
        padding: 1.5rem 1rem;
        width: 95%;
        border-radius: 15px;
        max-height: 65vh;
        overflow-y: auto;
    }
    
    h1 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .ready-message {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .flags-grid {
        padding: 1rem;
        padding-bottom: 65vh; /* Ensure all flags can scroll up past the bottom-docked card */
    }
    
    .flag-item {
        width: 60px;
    }
    
    .flag-emoji {
        font-size: 2.2rem;
    }
    
    .flag-name {
        font-size: 0.7rem;
    }
    
    #status-message {
        margin-bottom: 1rem;
        font-size: 0.8rem;
    }
    
    textarea {
        height: 150px;
        padding: 10px;
    }
    
    #go-btn {
        padding: 10px 20px;
        font-size: 1rem;
    }
    
    .ai-btn {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
}
