.ld-city-map {
    --map-dot: color-mix(in srgb, var(--text) 26%, var(--bg));
    --map-dot-strong: color-mix(in srgb, var(--text) 10%, var(--bg));
    --map-line: color-mix(in srgb, var(--text) 40%, var(--bg));
    --map-wall: color-mix(in srgb, var(--accent) 45%, var(--bg));
    --map-lift: -9px;
    --map-stroke: 1.1;
    --map-dot-gap: 8;
    --map-dot-size: 1.6;
    --map-dim: 0.4;
    position: relative;
    max-width: min(var(--map-max-w), calc(var(--map-max-h) / var(--map-ratio)));
    margin: calc(min(var(--map-max-h), var(--map-ratio) * min(var(--map-max-w), 100%)) * var(--map-pull)) auto 32px;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

[data-theme="dark"] .ld-city-map {
    --map-dot: color-mix(in srgb, var(--text) 24%, var(--bg));
    --map-dot-strong: color-mix(in srgb, var(--text) 11%, var(--bg));
    --map-line: color-mix(in srgb, var(--text) 38%, var(--bg));
}

.ld-city-map {
    --map-grid-size: 40px;
    --map-grid-line: color-mix(in srgb, var(--text) 15%, transparent);
    --map-grid-fade: 35%;
    isolation: isolate;
}

.ld-city-map::before {
    content: "";
    position: absolute;
    inset: -12% -30%;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(var(--map-grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--map-grid-line) 1px, transparent 1px);
    background-size: var(--map-grid-size) var(--map-grid-size);
    background-position: center;
    -webkit-mask-image: radial-gradient(closest-side, #000 var(--map-grid-fade), transparent);
    mask-image: radial-gradient(closest-side, #000 var(--map-grid-fade), transparent);
}

.ld-city-map:first-child {
    margin-top: 0;
}

.ld-city-map:first-child::before {
    top: 0;
}

.ld-city-map-svg {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    transform: perspective(var(--map-depth)) rotateX(var(--map-tilt));
    transform-origin: 50% 100%;
}

.ld-city-map-svg .ld-city-wall path {
    fill: var(--map-wall);
    stroke: var(--map-wall);
    pointer-events: none;
}

.ld-city-wall {
    animation: city-wall 0.22s ease both;
}

@keyframes city-wall {
    from {
        opacity: 0;
    }
}

.ld-map-dot-bg {
    fill: var(--bg);
}

.ld-map-dot {
    fill: var(--map-dot);
}

.ld-map-dot-strong {
    fill: var(--map-dot-strong);
}

.ld-city-lands path {
    fill: url(#ld-map-dots);
    stroke: var(--map-line);
    stroke-width: var(--map-stroke);
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    transition: opacity 0.2s ease;
}

.ld-city-map.is-focus .ld-city-lands path:not(.is-hover, .ld-city-wall path) {
    opacity: var(--map-dim);
}

.ld-city-map-svg path.is-on {
    cursor: pointer;
    transform-box: fill-box;
    transform-origin: center;
    transition: fill 0.2s ease, opacity 0.2s ease, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ld-city-map-svg path.is-hover {
    fill: var(--accent);
    stroke: var(--accent);
    transform: translate(0, var(--map-lift));
}

.ld-city-map.is-wave path.is-on:not(.is-hover) {
    animation: city-wave 0.7s ease var(--d, 0s) both;
}

@keyframes city-wave {
    0%,
    100% {
        fill: url(#ld-map-dots);
    }

    20%,
    60% {
        fill: url(#ld-map-dots-strong);
    }
}

.ld-city-tip {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    box-shadow: var(--shadow);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, calc(-100% - 6px));
    transition: opacity 0.16s ease, transform 0.2s ease;
}

.ld-city-tip.is-visible {
    opacity: 1;
    transform: translate(-50%, calc(-100% - 12px));
}

.ld-city-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 24px;
    counter-reset: city;
    max-width: 720px;
    margin: 0 auto;
    padding: 0;
    list-style: none;
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
    color: var(--text-3);
    -webkit-tap-highlight-color: transparent;
}

.ld-city-list li {
    display: flex;
    gap: 10px;
    min-width: 0;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    counter-increment: city;
    transition: color 0.2s ease;
}

.ld-city-list li::before {
    content: counter(city, decimal-leading-zero);
    flex: none;
    min-width: 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 19.5px;
    color: color-mix(in srgb, var(--text-3) 70%, transparent);
}

@media (max-width: 900px) {
    .ld-city-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.ld-city-list li.is-active {
    color: var(--accent);
}

.ld-city-map-svg path.is-link {
    cursor: pointer;
}

.ld-city-list a {
    color: var(--text-2);
    text-decoration: none;
}

.ld-city-list li.is-active a,
.ld-city-list a:hover {
    color: var(--accent);
}

.ld-city-list.is-clipped {
    overflow: hidden;
    -webkit-mask-image: linear-gradient(180deg, #000 45%, transparent);
    mask-image: linear-gradient(180deg, #000 45%, transparent);
}

.ld-city-more {
    display: block;
    margin: 8px auto 0;
    padding: 6px 10px;
    border: 0;
    background: none;
    font: inherit;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    transition: color 0.2s ease;
}

.ld-city-more:hover {
    color: var(--text);
}

@media (max-width: 560px) {
    .ld-city-map {
        --map-line: color-mix(in srgb, var(--text) 32%, var(--bg));
        --map-stroke: 0.7;
        --map-dot-gap: 5;
        --map-dot-size: 1;
        margin-bottom: 22px;
    }

    [data-theme="dark"] .ld-city-map {
        --map-line: color-mix(in srgb, var(--text) 30%, var(--bg));
    }

    .ld-city-tip {
        font-size: 12px;
    }

    .ld-city-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 16px;
        font-size: 12.5px;
    }

    .ld-city-list li::before {
        line-height: 18.75px;
    }
}
