:root {
    --background: #050b12;
    --panel: rgba(11, 22, 34, 0.94);
    --panel-soft: rgba(15, 30, 45, 0.88);
    --border: rgba(142, 190, 219, 0.18);
    --text: #edf7ff;
    --muted: #8fa9bb;
    --birth: #3be7ff;
    --birth-soft: rgba(59, 231, 255, 0.18);
    --death: #ff5277;
    --death-soft: rgba(255, 82, 119, 0.18);
    --net: #ffd166;
    --land: #172d3d;
    --land-hover: #23475e;
    --land-selected: #316d89;
    --ocean: #07131e;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    background:
        radial-gradient(circle at 40% 30%, #10283a 0%, transparent 40%),
        linear-gradient(145deg, #07111b, #02070c);
    color: var(--text);
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
}

body {
    overflow: hidden;
}

button,
input {
    font: inherit;
}

.topbar {
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 22px;
    border-bottom: 1px solid var(--border);
    background: rgba(4, 10, 17, 0.94);
    backdrop-filter: blur(16px);
    position: relative;
    z-index: 20;
}

.branding {
    display: flex;
    align-items: center;
    gap: 13px;
}

.globe-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(59, 231, 255, 0.45);
    border-radius: 50%;
    color: var(--birth);
    font-size: 28px;
    box-shadow:
        inset 0 0 18px rgba(59, 231, 255, 0.13),
        0 0 18px rgba(59, 231, 255, 0.08);
}

h1,
h2,
p {
    margin-top: 0;
}

.branding h1 {
    margin-bottom: 2px;
    font-size: clamp(1.05rem, 2vw, 1.55rem);
    letter-spacing: 0.01em;
}

.branding p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.status-area {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #bcd1df;
    font-size: 0.85rem;
}

.live-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #4dff91;
    box-shadow: 0 0 12px #4dff91;
    animation: statusPulse 1.6s infinite;
}

@keyframes statusPulse {
    50% {
        opacity: 0.35;
    }
}

main {
    height: calc(100vh - 78px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
}

.map-panel {
    min-width: 0;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at center, rgba(24, 67, 93, 0.22), transparent 55%),
        var(--ocean);
}

#worldMap {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

#worldMap:active {
    cursor: grabbing;
}

.country {
    fill: var(--land);
    stroke: rgba(117, 170, 199, 0.42);
    stroke-width: 0.5;
    vector-effect: non-scaling-stroke;
    transition: fill 140ms ease;
}

.country:hover {
    fill: var(--land-hover);
}

.country.selected {
    fill: var(--land-selected);
    stroke: var(--birth);
    stroke-width: 1.2;
}

.graticule {
    fill: none;
    stroke: rgba(103, 163, 195, 0.12);
    stroke-width: 0.5;
    vector-effect: non-scaling-stroke;
}

.sphere {
    fill: rgba(8, 25, 38, 0.36);
    stroke: rgba(110, 172, 205, 0.22);
    stroke-width: 1;
}

.event-ring {
    fill: none;
    pointer-events: none;
    vector-effect: non-scaling-stroke;
}

.event-core {
    pointer-events: none;
    vector-effect: non-scaling-stroke;
}

.birth-ring {
    stroke: var(--birth);
}

.birth-core {
    fill: #d6fbff;
    stroke: var(--birth);
}

.death-ring {
    stroke: var(--death);
}

.death-core {
    fill: #ffe1e8;
    stroke: var(--death);
}

.dashboard {
    padding: 14px;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    background: rgba(4, 10, 17, 0.93);
}

.counter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.counter-card,
.control-card,
.country-card,
.information-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background:
        linear-gradient(145deg, rgba(18, 37, 53, 0.88), rgba(8, 17, 27, 0.94));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

.counter-card {
    min-height: 115px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.counter-label,
.eyebrow {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.11em;
}

.counter-card strong {
    margin: 7px 0 3px;
    font-size: clamp(1.45rem, 3vw, 2rem);
    line-height: 1;
}

.counter-card small {
    color: var(--muted);
    line-height: 1.3;
}

.birth-card strong {
    color: var(--birth);
}

.death-card strong {
    color: var(--death);
}

.net-card strong {
    color: var(--net);
}

.control-card,
.country-card,
.information-card {
    margin-top: 12px;
    padding: 16px;
}

.control-card h2,
.country-card h2,
.information-card h2 {
    margin-bottom: 13px;
    font-size: 1rem;
}

.control-card > label {
    display: flex;
    justify-content: space-between;
    color: #cadae4;
    font-size: 0.84rem;
}

#speedControl {
    width: 100%;
    margin: 14px 0;
    accent-color: var(--birth);
}

.button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

button {
    min-height: 42px;
    padding: 9px 14px;
    border: 1px solid rgba(130, 189, 221, 0.24);
    border-radius: 9px;
    background: #142b3c;
    color: var(--text);
    cursor: pointer;
}

button:hover {
    background: #1b3b51;
    border-color: rgba(59, 231, 255, 0.5);
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 13px;
    color: #c1d2dd;
    font-size: 0.82rem;
}

.toggle-row label {
    display: flex;
    align-items: center;
    gap: 7px;
}

.toggle-row input {
    accent-color: var(--birth);
}

.country-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.country-heading h2 {
    margin: 4px 0 12px;
    font-size: 1.25rem;
}

#clearCountry {
    width: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.3rem;
}

.search-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.75rem;
}

#countrySearch {
    width: 100%;
    min-height: 42px;
    padding: 8px 11px;
    border: 1px solid rgba(131, 185, 214, 0.28);
    border-radius: 9px;
    outline: none;
    background: #081722;
    color: var(--text);
}

#countrySearch:focus {
    border-color: var(--birth);
    box-shadow: 0 0 0 3px rgba(59, 231, 255, 0.1);
}

.country-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    margin-top: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--border);
}

.country-stats div {
    min-height: 70px;
    padding: 11px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #0b1925;
}

.country-stats span {
    color: var(--muted);
    font-size: 0.72rem;
}

.country-stats strong {
    margin-top: 5px;
    font-size: 0.97rem;
}

.information-card p {
    margin-bottom: 9px;
    color: #9fb4c2;
    font-size: 0.77rem;
    line-height: 1.5;
}

.information-card p:last-child {
    margin-bottom: 0;
}

.legend {
    position: absolute;
    left: 17px;
    bottom: 17px;
    display: flex;
    gap: 15px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(3, 10, 17, 0.82);
    color: #bbccd7;
    font-size: 0.76rem;
    backdrop-filter: blur(10px);
}

.legend span {
    display: flex;
    align-items: center;
    gap: 7px;
}

.legend i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.birth-key {
    background: var(--birth);
    box-shadow: 0 0 10px var(--birth);
}

.death-key {
    background: var(--death);
    box-shadow: 0 0 10px var(--death);
}

.zoom-hint {
    position: absolute;
    right: 17px;
    bottom: 17px;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(3, 10, 17, 0.76);
    color: var(--muted);
    font-size: 0.7rem;
}

.tooltip {
    position: fixed;
    z-index: 50;
    max-width: 245px;
    padding: 10px 12px;
    border: 1px solid rgba(59, 231, 255, 0.35);
    border-radius: 9px;
    background: rgba(3, 11, 18, 0.96);
    color: var(--text);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
    pointer-events: none;
    opacity: 0;
    transform: translate(10px, 10px);
    transition: opacity 100ms ease;
}

.tooltip strong {
    display: block;
    margin-bottom: 5px;
}

.tooltip span {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.45;
}

.loading-panel {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(3, 10, 17, 0.91);
}

.loading-panel.hidden {
    display: none;
}

.loader {
    width: 46px;
    height: 46px;
    border: 3px solid rgba(59, 231, 255, 0.18);
    border-top-color: var(--birth);
    border-radius: 50%;
    animation: spin 900ms linear infinite;
}

.loading-panel span {
    color: var(--muted);
    font-size: 0.85rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1050px) {
    body {
        overflow: auto;
    }

    main {
        height: auto;
        min-height: calc(100vh - 78px);
        grid-template-columns: 1fr;
    }

    .map-panel {
        height: 62vh;
        min-height: 470px;
    }

    .dashboard {
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .counter-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 720px) {
    .topbar {
        height: auto;
        min-height: 70px;
        padding: 10px 12px;
    }

    .globe-mark {
        width: 38px;
        height: 38px;
        font-size: 22px;
    }

    .branding p,
    .status-area {
        display: none;
    }

    main {
        min-height: calc(100vh - 70px);
    }

    .map-panel {
        height: 53vh;
        min-height: 380px;
    }

    .dashboard {
        padding: 10px;
    }

    .counter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .counter-card {
        min-height: 100px;
        padding: 11px;
    }

    .zoom-hint {
        display: none;
    }

    .legend {
        right: 10px;
        left: 10px;
        bottom: 10px;
        justify-content: center;
    }
}
