@font-face {
    font-family: "Noto Sans";
    src: url("/fonts/NotoSans-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-display: swap;
}

/* The interface colours: the bot's Default embed theme. state.js (INTERFACE_THEMES) swaps them per theme */
:root {
    --bg: #000a26;
    --panel: rgba(0, 17, 61, 0.88);
    --panel-solid: #001a52;
    --line: rgba(255, 255, 255, 0.1);
    --text: #f2f4fa;
    --muted: #9aa6c4;
    --accent: #fcc306;
    --on-accent: #1b1400;
    --field: rgba(255, 255, 255, 0.07);
    --field-hover: rgba(255, 255, 255, 0.12);
    --radius: 10px;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.4 "Noto Sans", system-ui, sans-serif;
    font-weight: 600;
    -webkit-font-smoothing: antialiased;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

#stage {
    position: fixed;
    inset: 0;
    touch-action: none;
    cursor: grab;
}

#stage.dragging {
    cursor: grabbing;
}

#stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#overlay {
    pointer-events: none;
}

.panel {
    background: var(--panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

button,
select,
input {
    font: inherit;
    color: inherit;
}

select,
input[type="search"] {
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 6px 10px;
    min-height: 34px;
    outline: none;
}

select:hover,
input[type="search"]:hover {
    background: var(--field-hover);
}

select:focus-visible,
input:focus-visible,
button:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

select option {
    background: var(--panel-solid);
}

.icon-button,
.text-button {
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 7px;
    min-width: 34px;
    min-height: 34px;
    cursor: pointer;
    line-height: 1;
}

.icon-button {
    font-size: 20px;
    padding: 0 8px;
}

.text-button {
    padding: 0 12px;
}

.icon-button:hover,
.text-button:hover {
    background: var(--field-hover);
}

.text-button:disabled {
    opacity: 0.45;
    cursor: default;
}

/* Top bar */
.bar {
    position: fixed;
    top: 12px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px 7px 14px;
    max-width: calc(100vw - 24px);
}

.brand {
    font-size: 16px;
    margin: 0 6px 0 0;
    letter-spacing: 0.02em;
    color: var(--accent);
}

.search input {
    width: 220px;
}

.settings {
    position: relative;
}

.settings summary {
    list-style: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: var(--field);
    border: 1px solid var(--line);
    cursor: pointer;
    color: var(--muted);
}

.settings summary::-webkit-details-marker {
    display: none;
}

.settings[open] summary,
.settings summary:hover {
    color: var(--text);
    background: var(--field-hover);
}

.settings-menu {
    position: absolute;
    top: 42px;
    right: 0;
    width: 250px;
    padding: 12px;
    display: grid;
    gap: 10px;
    background: var(--panel-solid);
}

.settings-menu label {
    display: grid;
    gap: 4px;
    color: var(--muted);
}

.settings-menu label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    cursor: pointer;
}

.settings-menu input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    margin: 0;
}

/* Timeline */
.timeline {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    width: min(760px, calc(100vw - 24px));
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
}

#slider {
    flex: 1;
    min-width: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.when {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 132px;
    font-variant-numeric: tabular-nums;
}

#when {
    white-space: nowrap;
}

.badge {
    font-size: 11px;
    color: var(--on-accent);
    background: var(--accent);
    border-radius: 4px;
    padding: 0 5px;
    margin-top: 2px;
}

/* Legend */
.legend {
    position: fixed;
    left: 12px;
    bottom: 76px;
    padding: 10px 12px;
    width: 220px;
    display: grid;
    gap: 6px;
}

.legend-bar {
    height: 10px;
    border-radius: 3px;
    background: linear-gradient(90deg, #ffffff, #ff0000);
}

.legend-scale {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

/* Province panel */
.side {
    position: fixed;
    top: 12px;
    right: 12px;
    bottom: 76px;
    width: 340px;
    overflow-y: auto;
    padding: 16px 16px 20px;
    background: var(--panel-solid);
}

#panel-close {
    position: absolute;
    top: 10px;
    right: 10px;
}

.side h2 {
    font-size: 19px;
    margin: 0 40px 2px 0;
    line-height: 1.25;
}

.side .sub {
    color: var(--muted);
    margin-bottom: 14px;
}

.side h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 18px 0 8px;
}

.owner {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    background: var(--field);
    border: 1px solid var(--line);
}

.owner+.owner {
    margin-top: 6px;
}

.owner button {
    all: unset;
    display: block;
    cursor: pointer;
}

.owner button:hover .owner-name {
    text-decoration: underline;
}

.owner .empire-link {
    display: inline;
}

.owner .empire-link:hover {
    text-decoration: underline;
}

.swatch {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    flex: none;
    border: 1px solid rgba(128, 128, 128, 0.5);
}

.owner-name {
    display: block;
}

.owner-meta {
    color: var(--muted);
    font-size: 12px;
}

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.stat {
    background: var(--field);
    border-radius: 8px;
    padding: 8px 10px;
}

.stat b {
    display: block;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

.stat span {
    color: var(--muted);
    font-size: 12px;
}

.rows {
    display: grid;
    gap: 2px;
}

.row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border-bottom: 1px solid var(--line);
}

.row span:last-child {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.muted {
    color: var(--muted);
}

/* Tooltip, loading, toast */
.tooltip {
    position: fixed;
    pointer-events: none;
    background: var(--panel-solid);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 6px 9px;
    box-shadow: var(--shadow);
    max-width: 260px;
    z-index: 10;
}

.tooltip .muted {
    font-size: 12px;
}

.loading {
    position: fixed;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 12px;
    background: var(--bg);
    transition: opacity 0.3s;
    z-index: 20;
}

.loading.done {
    opacity: 0;
    pointer-events: none;
}

.loading.busy {
    background: transparent;
    inset: auto auto 76px 50%;
    transform: translateX(-50%);
    grid-auto-flow: column;
}

.loading.busy span {
    display: none;
}

.spinner {
    width: 26px;
    height: 26px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.toast {
    position: fixed;
    top: 66px;
    left: 50%;
    transform: translateX(-50%);
    background: #5a1d1d;
    border: 1px solid #8a2f2f;
    border-radius: 8px;
    padding: 8px 14px;
    z-index: 30;
    max-width: calc(100vw - 32px);
}

/* Phones: the bar wraps, the panel becomes a bottom sheet */
@media (max-width: 640px) {
    .bar {
        left: 8px;
        right: 8px;
        top: 8px;
        flex-wrap: wrap;
        padding: 7px;
    }

    .brand {
        display: none;
    }

    .search {
        flex: 1;
    }

    .search input {
        width: 100%;
    }

    .timeline {
        bottom: 8px;
        width: calc(100vw - 16px);
    }

    .when {
        min-width: 0;
    }

    #when {
        font-size: 12px;
    }

    .side {
        top: auto;
        left: 8px;
        right: 8px;
        bottom: 66px;
        width: auto;
        max-height: 55vh;
    }

    .legend {
        left: 8px;
        bottom: 66px;
    }

    .side:not([hidden])~.legend {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 2.4s;
    }

    .loading {
        transition: none;
    }
}