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

body,
html {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #080d1a;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #ffffff;
}

.map-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

svg {
    width: 100%;
    height: 100%;
    background-color: #080d1a;
    cursor: grab;
}

svg:active {
    cursor: grabbing;
}

/* Map Elements */
.ocean-sphere {
    fill: #0d1b2a;
    stroke: #1b263b;
    stroke-width: 1px;
}

.graticule {
    fill: none;
    stroke: #1e293b;
    stroke-width: 0.5px;
    stroke-dasharray: 2 2;
    pointer-events: none;
}

.country {
    fill: #1c2541;
    stroke: #3a506b;
    stroke-width: 0.5px;
    cursor: pointer;
    transition: fill 0.2s ease, stroke 0.2s ease;
}

.country:hover {
    fill: #00b4d8 !important;
    stroke: #ffffff;
}

.country.selected {
    fill: #ffb703 !important;
    stroke: #ffffff;
}

/* Top Controls Bar */
.top-bar {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    z-index: 20;
    pointer-events: none;
    transition: right 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Shifts top bar left when drawer opens */
.top-bar.drawer-open {
    right: 400px;
}

.top-bar>* {
    pointer-events: auto;
}

.search-box-container {
    position: relative;
    width: 320px;
}

.search-input {
    width: 100%;
    padding: 10px 16px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid #334155;
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.9rem;
    outline: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: #00b4d8;
}

.search-results {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid #334155;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 50;
}

.search-results.active {
    display: block;
}

.search-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #1e293b;
}

.search-item:hover {
    background: #1e293b;
    color: #00b4d8;
}

.search-item .sub {
    color: #64748b;
    font-size: 0.75rem;
}

/* Toolbar Options */
.toolbar {
    display: flex;
    gap: 8px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    padding: 6px;
    border: 1px solid #334155;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tool-btn,
.select-btn {
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid #334155;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn:hover,
.select-btn:hover {
    background: #334155;
    color: #ffffff;
}

.tool-btn.active {
    background: #00b4d8;
    color: #080d1a;
    border-color: #00b4d8;
}

select.select-btn {
    outline: none;
}

/* Map Zoom Control Group */
.controls {
    position: absolute;
    top: 80px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
    transition: right 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.controls.drawer-open {
    right: 400px;
}

.control-btn {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    color: #00b4d8;
    border: 1px solid #334155;
    width: 38px;
    height: 38px;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #1e293b;
    color: #ffffff;
}

.tooltip {
    position: absolute;
    padding: 6px 12px;
    background: #ffffff;
    color: #080d1a;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -130%);
    transition: opacity 0.1s ease;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    z-index: 30;
}

/* Side Atlas Drawer (Expanded for Full JSON display) */
.drawer {
    position: absolute;
    top: 0;
    right: -380px;
    width: 380px;
    height: 100%;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(12px);
    border-left: 1px solid #334155;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.6);
    transition: right 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 40;
    display: flex;
    flex-direction: column;
}

.drawer.open {
    right: 0;
}

.drawer-header {
    padding: 20px;
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: rgba(30, 41, 59, 0.5);
}

.drawer-title-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.close-drawer {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
}

.close-drawer:hover {
    color: #ffffff;
}

.drawer-content {
    padding: 20px;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.data-card {
    background: #1e293b;
    border: 1px solid #334155;
    padding: 8px 12px;
    border-radius: 6px;
}

.data-card.full-width {
    grid-column: span 2;
}

.data-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #00b4d8;
    margin-bottom: 3px;
}

.data-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #f1f5f9;
    line-height: 1.3;
    word-break: break-word;
}

.badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.badge {
    background: #0f172a;
    border: 1px solid #334155;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #94a3b8;
}

.badge.highlight {
    border-color: #00b4d8;
    color: #00b4d8;
}

.live-time {
    color: #ffb703;
    font-family: monospace;
    font-size: 1rem;
}

.legend {
    position: absolute;
    bottom: 24px;
    left: 16px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid #334155;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.75rem;
    display: none;
    z-index: 10;
}

.legend.active {
    display: block;
}

.legend-scale {
    display: flex;
    height: 8px;
    width: 160px;
    border-radius: 4px;
    overflow: hidden;
    margin: 6px 0 4px;
}

.legend-scale div {
    flex: 1;
}

.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    color: #00b4d8;
}