/**
 * Geography Game — Mobile-first styles
 * Touch-friendly targets; works on small screens.
 */

:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --success: #3fb950;
    --error: #f85149;
    --info: #79c0ff;
    --continent-fill: #2d4a3e;
    --continent-stroke: #52b788;
    --country-fill: #1e3a5f;
    --country-stroke: #58a6ff;
    --tap-min: 44px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--surface);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.score-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.score {
    font-weight: 600;
    color: var(--accent);
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    background: rgba(88, 166, 255, 0.2);
    border-radius: 4px;
    color: var(--accent);
}

.next-badge {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main */
.main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

/* Messages */
.message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.message-success {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}

.message-error {
    background: rgba(248, 81, 73, 0.15);
    color: var(--error);
}

.message-info {
    background: rgba(121, 192, 255, 0.15);
    color: var(--info);
}

/* Steps */
.step {
    margin-bottom: 1.5rem;
}

.prompt {
    font-size: 1.25rem;
    margin: 0 0 0.5rem;
}

.subprompt {
    color: var(--text-muted);
    margin: 0 0 1rem;
}

/* Map container: responsive, touch-friendly */
.map-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 0 1rem;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
}

.map-wrap svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
}

/* World-geo paths (country polygons) */
.map-world svg.world-map.geo path {
    cursor: pointer;
    transition: filter 0.15s ease;
}

.map-world svg.world-map.geo path:hover,
.map-world svg.world-map.geo path:focus {
    filter: brightness(1.25);
    outline: none;
}

.map-world svg.world-map.geo path:active {
    filter: brightness(1.1);
}

/* Continent regions (world map): paths are transparent; show visible fill on hover/focus */
.map-wrap .continent path {
    fill: transparent;
    stroke: none;
    transition: fill 0.2s ease, stroke 0.2s ease;
}
.map-wrap .continent:hover path,
.map-wrap .continent:focus path,
.map-wrap .continent path:hover,
.map-wrap .continent path:focus {
    fill: rgba(82, 183, 136, 0.45);
    stroke: rgba(82, 183, 136, 0.9);
    stroke-width: 1.5;
    outline: none;
}
.map-wrap .continent:active path,
.map-wrap .continent path:active {
    fill: rgba(82, 183, 136, 0.55);
}

.map-wrap .continent,
.map-wrap .country {
    cursor: pointer;
    transition: filter 0.15s ease;
}

/* Highlight the correct country region after feedback (g with path inside, or path itself) */
.map-wrap .country.is-correct-target path,
.map-wrap path.country.is-correct-target {
    fill: var(--success);
    stroke: #ffffff;
    stroke-width: 1.5;
}

/* Success highlight with checkmark animation */
.map-wrap .country.is-correct-success path,
.map-wrap path.country.is-correct-success {
    fill: var(--success);
    stroke: #ffffff;
    stroke-width: 2;
    animation: success-pulse 0.6s ease-out;
}

@keyframes success-pulse {
    0% {
        filter: brightness(1.5) drop-shadow(0 0 8px var(--success));
        transform: scale(1);
    }
    50% {
        filter: brightness(1.8) drop-shadow(0 0 16px var(--success));
        transform: scale(1.05);
    }
    100% {
        filter: brightness(1.2) drop-shadow(0 0 4px var(--success));
        transform: scale(1);
    }
}

/* Checkmark overlay for success - positioned on map-wrap */
.map-wrap.map-continent.has-success-highlight::before {
    content: '✓';
    position: absolute;
    font-size: 8rem;
    font-weight: bold;
    color: var(--success);
    text-shadow: 0 0 30px rgba(63, 185, 80, 1), 0 0 15px rgba(63, 185, 80, 0.9), 0 0 5px rgba(63, 185, 80, 0.8);
    pointer-events: none;
    z-index: 100;
    animation: checkmark-appear 0.6s ease-out;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation-fill-mode: forwards;
    line-height: 1;
}

@media (min-width: 768px) {
    .map-wrap.map-continent.has-success-highlight::before {
        font-size: 12rem;
    }
}

@keyframes checkmark-appear {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-45deg);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2) rotate(5deg);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
}

.map-wrap .country:hover,
.map-wrap .country:focus {
    filter: brightness(1.25);
    outline: none;
}

.map-wrap .country:active {
    filter: brightness(1.1);
}

.map-placeholder {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-block;
    min-height: var(--tap-min);
    padding: 0.6rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent);
    color: var(--bg);
}

.btn-primary:hover,
.btn-primary:focus {
    background: #79b8ff;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover,
.btn-secondary:focus {
    color: var(--text);
    border-color: var(--text-muted);
}

/* Fact step */
.step-fact h2 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
}

.step-fact .fact {
    font-size: 1.1rem;
    margin: 0 0 1.5rem;
    color: var(--text);
}

.step-fact .btn {
    margin-top: 0.5rem;
}
