:root {
    --bg-color: #111827; 
    --ui-panel-bg: rgba(31, 41, 55, 0.6); 
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --accent-color: #38bdf8; 
    --accent-hover: #0ea5e9;
    --border-color: rgba(107, 114, 128, 0.3);
    --default-state: #4b5563;
    --highlighted-state: var(--accent-color);
    --correct-state: #34d399; 
    --highlight-stroke: #facc15; 
    --incorrect-feedback-color: #fb7185; 
    --font-sans: 'Inter', sans-serif;
    --font-display: 'Bebas Neue', cursive;
    --ui-panel-width: 380px;
    --ui-panel-border-radius: 1.5rem;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

/* --- Base & Full-Screen Shell --- */
*, *::before, *::after { box-sizing: border-box; }

html, body, #app-shell {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    background-color: var(--bg-color);
    font-family: var(--font-sans);
    color: var(--text-primary);
    margin: 0;
}

#app-shell {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.background-texture {
    position: absolute;
    inset: 0;
    background-image: url('data:image/svg+xml,%3Csvg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"%3E%3Cg fill="none" fill-rule="evenodd"%3E%3Cg fill="%239C92AC" fill-opacity="0.04"%3E%3Cpath d="M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z"/%3E%3C/g%3E%3C/g%3E%3C/svg%3E');
    opacity: 0.5;
}

/* --- Global Animations --- */
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.earth-emoji { display: inline-block; animation: spin 12s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* --- Selection Screen --- */
.selection-container {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.5s ease-out;
}
.selection-content { text-align: center; }
.selection-content h1 {
    font-family: var(--font-display);
    font-size: 5rem;
    letter-spacing: 3px; margin-bottom: 0.5rem;
}
.selection-content p { font-size: 1.25rem; color: var(--text-secondary); margin-bottom: 3rem; }
.country-choices { display: flex; gap: 2rem; }
.country-button {
    background: transparent; border: 2px solid var(--border-color);
    border-radius: var(--ui-panel-border-radius);
    width: 280px; height: 350px;
    cursor: pointer; position: relative; overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.country-button:hover { 
    transform: translateY(-10px); 
    border-color: var(--accent-color); 
    box-shadow: 0 20px 40px var(--shadow-color); 
}
.country-button .map-bg {
    position: absolute; inset: 0;
    background: var(--bg-image) no-repeat center center; 
    background-size: 85% auto; 
    opacity: 0.1; 
    margin-bottom: 40px;
    filter: invert(1); 
    transition: opacity 0.3s ease;
}
.country-button:hover .map-bg { opacity: 0.4; }
.country-name {
    position: absolute; bottom: 2rem; left: 0; right: 0;
    font-size: 1.75rem; font-weight: 600;
    color: var(--text-primary); 
    transition: color 0.3s ease; 
}
.country-button:hover .country-name { color: var(--accent-color); }

/* --- Creator Credit --- */
.creator-credit {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-decoration: none;
    color: var(--text-secondary);
    opacity: 0.6;
    
    /* Smooth transition for hover */
    transition: all 0.3s ease;
}

.creator-credit:hover {
    color: var(--accent-color);
    opacity: 1;
    transform: translateY(-5px); /* Subtle slide effect on hover */
}

/* --- Game Container (Split-Screen Layout) --- */
.game-container {
    display: grid;
    grid-template-columns: var(--ui-panel-width) 1fr;
    width: 100%; height: 100%;
    padding: 1.5rem; gap: 1.5rem;
    animation: fadeIn 0.5s ease-out;
}

/* Map Panel (Right side) */
.map-panel { display: flex; align-items: center; justify-content: center; }
#map-container {
    width: 90%; height: 90%; 
    display: flex; align-items: center; justify-content: center;
    filter: drop-shadow(0 10px 20px var(--shadow-color));
}
#map-container svg { width: 100%; height: auto; max-width: 100%; max-height: 90vh; }
.state {
    fill: var(--default-state); stroke: var(--bg-color);
    stroke-width: 1px; transition: all 0.3s ease;
}
.state.highlighted {
    fill: var(--highlighted-state); stroke: var(--highlight-stroke); stroke-width: 2.5px;
}
.state.correct { fill: var(--correct-state); }

.state.incorrect-final {
    fill: var(--incorrect-feedback-color);
}

/* UI Panel (Left Side / Bottom Sheet) */
.ui-panel {
    background-color: var(--ui-panel-bg);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-radius: var(--ui-panel-border-radius);
    padding: 2rem;
    display: flex; flex-direction: column;
}

/* UI Panel Content Styling */
.game-header h1 { font-weight: 600; font-size: 1rem; color: var(--text-secondary); margin: 0; }
.progress-container { margin-top: 1rem; }
.stats-bar { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; }
.progress-text { margin-bottom: 0; display: block; font-size: 0.9rem; color: var(--text-secondary); }
.mistakes-counter {
    font-size: 0.9rem; font-weight: 600; color: var(--incorrect-feedback-color);
    background-color: rgba(251, 113, 133, 0.15);
    padding: 0.1rem 0.5rem; border-radius: 99px;
    opacity: 0; transition: opacity 0.3s ease;
}
.mistakes-counter.visible { opacity: 1; }
.progress-bar-container { background: rgba(0,0,0,0.3); border-radius: 99px; overflow: hidden; height: 0.5rem; }
.progress-bar { width: 0%; height: 100%; background: var(--accent-color); transition: width 0.5s ease-out; }

.game-controls { flex-grow: 1; display: flex; flex-direction: column; justify-content: flex-start; }
.game-controls p { font-size: 1.5rem; font-weight: 600; margin-bottom: 1.5rem; text-align: center; }
.choices-container { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.choice-button {
    background-color: rgba(255, 255, 255, 0.05); border: 1px solid var(--border-color);
    color: var(--text-primary); border-radius: 0.75rem; padding: 1rem;
    font-size: 1rem; font-weight: 600; text-align: left;
    cursor: pointer; transition: all 0.2s ease;
}
.choice-button:hover:not(:disabled) { background-color: rgba(255, 255, 255, 0.1); border-color: var(--accent-color); }
.choice-button.correct-feedback { border-color: var(--correct-state); background: rgba(52, 211, 153, 0.1); }
.choice-button.incorrect-feedback { border-color: var(--incorrect-feedback-color); background: rgba(251, 113, 133, 0.1); }

.game-footer { display: flex; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }
.secondary-button, .reset-button {
    flex: 1; padding: 0.8rem; border-radius: 0.75rem; border: none;
    font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: background-color 0.2s;
}
.game-footer button svg {
    display: none; /* Hide icons on desktop by default */
}
.game-footer button span {
    display: inline; /* Ensure text is visible */
}
.secondary-button { background-color: var(--default-state); color: var(--text-primary); }
.secondary-button:hover { background-color: #6b7280; }
.reset-button { background-color: rgba(251, 113, 133, 0.2); color: var(--incorrect-feedback-color); }
.reset-button:hover { background-color: rgba(251, 113, 133, 0.4); }


.pulsing-clone {
    fill: #ffcc008f; 
    filter: blur(10px);
    stroke: none; 
    pointer-events: none; 
        animation: pulse-effect 1.5s infinite ease-out;
}

@keyframes pulse-effect {
    0% {
        transform: scale(0.7);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.8); 
        opacity: 0;
    }
}

/* --- Summary Card Styles --- */
.completion-message { 
    text-align: center; 
    animation: fadeIn 0.5s ease-out;
}
.completion-message h2 { font-family: var(--font-display); letter-spacing: 1px; font-size: 2.5rem; margin-bottom: 0.25rem; }
.completion-message #completion-subtitle { font-size: 1.1rem; color: var(--text-secondary); margin-top: 0; }

.summary-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.stat-item {
    --stat-color: var(--text-secondary); /* Default color */
    background: linear-gradient(145deg, rgba(255,255,255,0.05), rgba(255,255,255,0));
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--stat-color);
    border-radius: 1rem;
    padding: 1rem;
    display: grid;
    grid-template-columns: 40px 1fr;
    grid-template-rows: auto auto;
    grid-template-areas: 
        "icon label"
        "icon value";
    align-items: center;
    gap: 0 1rem;
    opacity: 0; /* For animation */
    animation: popIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    transition: transform 0.2s ease-out;
}
.stat-item:hover {
    transform: scale(1.03);
}

/* Staggered animation */
#accuracy-stat-item { animation-delay: 0.1s; }
#mistakes-stat-item { animation-delay: 0.2s; }

/* Color theming */
#time-stat-item     { --stat-color: var(--accent-color); }
#accuracy-stat-item { --stat-color: var(--correct-state); }
#mistakes-stat-item { --stat-color: var(--incorrect-feedback-color); }

.stat-icon {
    grid-area: icon;
    color: var(--stat-color);
}
.stat-icon svg {
    width: 32px;
    height: 32px;
}
.stat-label {
    grid-area: label;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.stat-value {
    grid-area: value;
    text-align: left;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


.shake-animation { animation: shake 0.5s ease-out; }
@keyframes shake { 0%,100% {transform:translateX(0)} 10%,30%,50%,70%,90% {transform:translateX(-5px)} 20%,40%,60%,80% {transform:translateX(5px)} }





/* --- Mobile Layout --- */
@media (max-width: 768px) {
    .selection-content { padding: 1rem; margin-top: 100px;}
    .selection-container {overflow: auto;}
    .country-choices { flex-direction: column; gap: 1rem; align-items: center; }
    .country-button { width: 90vw; max-width: 320px; height: 180px; }
    .country-button .map-bg { margin-bottom: 0px;}
    .country-name { font-size: 1.25rem; bottom: 1rem; }

    .creator-credit {
        position: static; 
        display: block; 
        margin: 3rem auto 2rem auto;
        transform: none; 
    }
    .creator-credit:hover {
        transform: translateY(-3px); /* Keep a subtle lift on hover */
    }

    #map-container svg {max-height: 60vh;}
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr; 
        padding: 0; gap: 0;
    }
    .map-panel { align-items: flex-end; padding-bottom: 2rem; }
    .ui-panel {
        width: 100%; border-radius: var(--ui-panel-border-radius) var(--ui-panel-border-radius) 0 0;
        animation: slideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
        padding: 1rem; padding-top: 1.5rem;
    }
    .game-controls p { font-size: 1.2rem; margin-top: 1.5rem; }
    
    .choices-container { 
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* Back to a 3-column grid */
        gap: 0.5rem; /* Tighter gap between buttons */
    }

    .choice-button {
        border-radius: 10px; /* Keep the pill shape */
        padding: 0.6rem 0.5rem; /* REDUCED: Less padding above/below and on sides */
        font-size: 0.85rem; /* REDUCED: Smaller font to fit better */
        text-align: center;

        /* Gracefully handle long names if they still don't fit */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }


.game-footer {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    margin-top: 0;
    gap: 0.75rem;
    /* Remove footer-like styling */
    background: none;
    padding: 0;
}

/* Hide the dev buttons on mobile for a cleaner UI */
.dev-button {
    display: none;
}

/* Transform the main buttons into circular icons */
.secondary-button, .reset-button {
    flex: 0 0 48px; /* Set a fixed size */
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--shadow-color);
}
.secondary-button {
    background-color: var(--ui-panel-bg);
    border: 1px solid var(--border-color);
}
.reset-button {
     background-color: var(--ui-panel-bg);
     border: 1px solid var(--border-color);
}

/* Swap text for icon */
.game-footer button span {
    display: none; /* Hide text on mobile */
}
.game-footer button svg {
    display: block; /* Show icons on mobile */
    width: 24px;
    height: 24px;
}
.reset-button svg {
    color: var(--incorrect-feedback-color);
}



}