@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Teko:wght@300;400;500&display=swap');

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

:root {
    --bg-panel: rgba(8, 10, 14, 0.82);
    --bg-panel-solid: #0a0c10;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #c8f230;
    --red: #ff3b3b;
    --text: #e8eaf0;
    --muted: rgba(232, 234, 240, 0.45);
    --font-mono: 'Share Tech Mono', monospace;
    --font-display: 'Teko', sans-serif;
}

body {
    font-family: var(--font-mono);
    background: #1a1f2e;
    overflow: hidden;
    color: var(--text);
}

/* ── MAP ── */
#map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='5' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3Cline x1='16' y1='0' x2='16' y2='10' stroke='%23000' stroke-width='1.5'/%3E%3Cline x1='16' y1='22' x2='16' y2='32' stroke='%23000' stroke-width='1.5'/%3E%3Cline x1='0' y1='16' x2='10' y2='16' stroke='%23000' stroke-width='1.5'/%3E%3Cline x1='22' y1='16' x2='32' y2='16' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E") 16 16, crosshair;
    filter: saturate(0.4) brightness(0.85);
}

/* ── HEADER PANEL ── */
header {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 14px 28px 16px;
    min-width: 340px;
    max-width: 520px;
    width: max-content;
}

header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent);
}

.instruction {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.town-wrapper {
    margin-bottom: 14px;
}

.town-label {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    display: block;
    margin-bottom: 4px;
}

.town-name {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: #fff;
    line-height: 1;
    display: block;
}

/* ── STATS ROW ── */
.statistics {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat-value {
    font-size: 18px;
    color: var(--text);
    line-height: 1;
}

.divider {
    width: 1px;
    height: 32px;
    background: var(--border);
    align-self: center;
}

/* ── TOAST ── */
#result-card {
    position: fixed;
    top: var(--header-h, 120px);
    left: 50%;
    transform: translateX(-50%) translateY(-110%);
    z-index: 998;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-panel-solid);
    border: 1px solid var(--border);
    border-top: none;
    padding: 8px 16px;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

#result-card.visible {
    transform: translateX(-50%) translateY(0);
}

#result-card.correct { border-bottom: 2px solid var(--accent); }
#result-card.wrong   { border-bottom: 2px solid var(--red); }

.result-city {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 400;
    color: #fff;
    line-height: 1;
}

.result-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.result-meta-item {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--muted);
    background: rgba(255,255,255,0.05);
    padding: 3px 8px;
}

.result-pts {
    color: var(--accent);
}

@media (max-width: 600px) {
    #result-card {
        left: 0;
        right: 0;
        width: 100%;
        transform: translateY(-110%);
        justify-content: center;
    }

    #result-card.visible {
        transform: translateY(0);
    }
}

/* ── CONFIRM BUTTON ── */
#confirm-btn {
    display: none;
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 0 40px;
    height: 48px;
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    background: var(--accent);
    color: #0a0c10;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    animation: slideUp 0.2s ease both;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#confirm-btn:hover {
    opacity: 0.88;
}

#confirm-btn:active {
    transform: translateX(-50%) scale(0.97);
}

[x-cloak] { display: none !important; }

/* ── GAME OVER OVERLAY ── */
.game-over-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.finish-panel {
    pointer-events: all;
}

/* ── FINISH PANEL ── */
.finish-panel {
    background: var(--bg-panel-solid);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    padding: 48px 56px;
    text-align: center;
    min-width: 360px;
}

.finish-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 32px;
}

.finish-score-bar {
    margin-bottom: 32px;
}

.finish-score-numbers {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 10px;
    justify-content: center;
}

.finish-score-current {
    font-family: var(--font-display);
    font-size: 56px;
    font-weight: 400;
    color: var(--accent);
    line-height: 1;
}

.finish-score-sep {
    font-family: var(--font-mono);
    font-size: 18px;
    color: var(--muted);
}

.finish-score-max {
    font-family: var(--font-mono);
    font-size: 18px;
    color: var(--muted);
}

.finish-bar-track {
    height: 6px;
    background: rgba(255,255,255,0.07);
    width: 100%;
}

.finish-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0;
}

.finish-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    margin-bottom: 36px;
}

.finish-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.finish-stat-value {
    font-family: var(--font-display);
    font-size: 52px;
    font-weight: 400;
    color: #fff;
    line-height: 1;
}

.finish-stat-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

.finish-stat-divider {
    width: 1px;
    height: 48px;
    background: var(--border);
}

.finish-btn {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    background: var(--accent);
    color: #0a0c10;
    border: none;
    padding: 14px 40px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.finish-btn:hover {
    opacity: 0.85;
}

/* ── MARKERS ── */
.marker-pending {
    width: 14px;
    height: 14px;
    background: var(--accent);
    border: 2px solid #0a0c10;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(200, 242, 48, 0.3);
    animation: pulse 1.4s ease infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(200, 242, 48, 0.3); }
    50%       { box-shadow: 0 0 0 6px rgba(200, 242, 48, 0.1); }
}

.marker-ripple {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    top: 0; left: 0;
    pointer-events: none;
    animation: ripple-out 1.2s ease-out forwards;
}

.marker-ripple.r2 { animation-delay: 0.25s; }
.marker-ripple.r3 { animation-delay: 0.5s; }

@keyframes ripple-out {
    0%   { transform: scale(0.1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.marker-correct {
    width: 14px;
    height: 14px;
    background: var(--accent);
    border: 2px solid #0a0c10;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(200, 242, 48, 0.5);
}

.marker-click {
    width: 10px;
    height: 10px;
    background: var(--red);
    border: 2px solid #0a0c10;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(255, 59, 59, 0.5);
}

/* ── NOTIFICATIONS ── */
.notifier {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    pointer-events: none;
}

/* ── MOBILE ── */
@media (max-width: 600px) {
    header {
        top: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        min-width: unset;
        max-width: unset;
        padding: 12px 16px 14px;
    }

    .instruction {
        font-size: 11px;
    }

    .town-name {
        font-size: 28px;
    }

    .town-label {
        font-size: 10px;
    }

    .town-wrapper {
        margin-bottom: 10px;
    }

    .stat-label {
        font-size: 10px;
    }

    .stat-value {
        font-size: 15px;
    }

    #confirm-btn {
        width: calc(100% - 32px);
        left: 16px;
        transform: none;
        bottom: 20px;
        padding: 0;
    }

    #confirm-btn:active {
        transform: scale(0.98);
    }

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

    .finish-panel {
        width: calc(100vw - 32px);
        min-width: unset;
        padding: 36px 24px;
    }

    .finish-stat-value {
        font-size: 40px;
    }

    .notifier {
        bottom: 80px;
        width: calc(100% - 32px);
        text-align: center;
    }
}
