:root {
    --tour-bar: clamp(52px, calc((100vh - 50vw) / 2), 14vh);
    --ink: #f3f5f8;
    --muted: rgba(243, 245, 248, 0.8);
    --glass: rgba(46, 52, 64, 0.64);
    --glass-edge: rgba(255, 255, 255, 0.13);
    --line: rgba(255, 255, 255, 0.22);
    --accent: #89bf2f;
    --accent-ink: #14200a;
    --panel-ink: #10141c;
    --day-track: linear-gradient(to right, #27304f 0%, #27304f 18%, #e8935a 27%, #8cc0f0 38%, #8cc0f0 66%, #e8935a 74%, #27304f 84%, #27304f 100%);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #0d1118;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

#scene {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

#labels {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.tilt {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.tilt[hidden] {
    display: none;
}

.tilt-zone {
    position: absolute;
    left: 0;
    right: 0;
    backdrop-filter: blur(1.6px);
    -webkit-backdrop-filter: blur(1.6px);
}

.tilt-zone.top {
    top: 0;
    height: 34vh;
    -webkit-mask-image: linear-gradient(to bottom, #000 20%, transparent);
    mask-image: linear-gradient(to bottom, #000 20%, transparent);
}

.tilt-zone.bottom {
    bottom: 0;
    height: 30vh;
    -webkit-mask-image: linear-gradient(to top, #000 20%, transparent);
    mask-image: linear-gradient(to top, #000 20%, transparent);
}

.tilt-zone.far {
    backdrop-filter: blur(3.5px);
    -webkit-backdrop-filter: blur(3.5px);
}

.tilt-zone.top.far {
    height: 17vh;
}

.tilt-zone.bottom.far {
    height: 15vh;
}

.label {
    position: absolute;
    left: 0;
    top: 0;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(16, 20, 28, 0.7);
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    will-change: transform;
}

.label::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    width: 1px;
    height: 14px;
    background: rgba(255, 255, 255, 0.55);
}

.label {
    pointer-events: auto;
    cursor: pointer;
}

.label.main {
    padding: 6px 14px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 15px;
    font-weight: 700;
}

.label.main::after {
    width: 2px;
    height: 22px;
    background: var(--accent);
}

.brand,
.hover-tip,
.info,
.about,
.toolbar,
.dock-bar,
.panel,
.credits {
    border: 1px solid var(--glass-edge);
    background: var(--glass);
    backdrop-filter: blur(16px) saturate(1.25);
    -webkit-backdrop-filter: blur(16px) saturate(1.25);
}

.brand {
    position: fixed;
    left: max(20px, env(safe-area-inset-left));
    top: max(18px, env(safe-area-inset-top));
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px 9px 11px;
    border-radius: 12px;
    cursor: pointer;
}

.brand-mark {
    flex: 0 0 auto;
    width: auto;
    height: 39px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
}

.brand-about {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    margin-left: 3px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    font: italic 700 13px/1 Georgia, "Times New Roman", serif;
    cursor: pointer;
}

.brand-about.active {
    border-color: transparent;
    background: var(--ink);
    color: var(--panel-ink);
}

@media (hover: hover) {
    .brand-about:hover {
        background: rgba(255, 255, 255, 0.16);
    }

    .brand-about.active:hover {
        background: var(--ink);
    }
}

.brand strong {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.brand span {
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.35;
}

.hover-tip {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 3;
    padding: 4px 9px;
    border-radius: 8px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

.hover-tip[hidden] {
    display: none;
}

.info {
    position: fixed;
    z-index: 3;
    left: max(20px, env(safe-area-inset-left));
    top: calc(78px + env(safe-area-inset-top));
    width: 300px;
    padding: 14px 40px 14px 16px;
    border-radius: 14px;
    line-height: 1.45;
}

.info strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
}

.info div {
    color: var(--muted);
    font-size: 13px;
}

.info .info-lead {
    margin: 2px 0 8px;
    color: var(--ink);
    line-height: 1.5;
}

.info a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.38);
    text-underline-offset: 3px;
}

.about {
    position: fixed;
    z-index: 4;
    left: max(20px, env(safe-area-inset-left));
    top: calc(78px + env(safe-area-inset-top));
    width: min(400px, calc(100vw - 40px));
    max-height: calc(100% - 190px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 16px 40px 16px 18px;
    border-radius: 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(34, 39, 49, 0.84);
    line-height: 1.5;
}

.about[hidden] {
    display: none;
}

.about h2 {
    margin: 18px 0 6px;
    font-size: 15px;
    line-height: 1.3;
}

.about h2:first-of-type {
    margin-top: 0;
}

.about h3 {
    margin: 12px 0 2px;
    font-size: 13px;
    line-height: 1.35;
}

.about p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.about .about-author {
    margin-top: 16px;
}

.about a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.38);
    text-underline-offset: 3px;
}

.about .close {
    position: sticky;
    float: right;
    top: 0;
    right: auto;
    margin: -6px -32px 0 0;
}

.close {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 28px;
    height: 28px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.corner {
    position: fixed;
    z-index: 3;
    right: max(20px, env(safe-area-inset-right));
    top: max(18px, env(safe-area-inset-top));
    pointer-events: none;
}

.toolbar {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    pointer-events: auto;
}

button {
    font: inherit;
}

.tool {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 124px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

@media (hover: hover) {
    .tool:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .tile:hover {
        background: rgba(255, 255, 255, 0.14);
    }

    .group button:hover {
        color: var(--ink);
    }

    .toggles button:hover,
    .play:hover {
        background: rgba(255, 255, 255, 0.15);
        color: var(--ink);
    }

    .credits a:hover {
        text-decoration-color: currentColor;
    }
}

.tool.active {
    background: var(--ink);
    color: var(--panel-ink);
}

.tool .icon {
    flex: 0 0 15px;
    width: 15px;
    height: 15px;
}

.icon-stop,
.tool.active .icon-start {
    display: none;
}

.tool.active .icon-stop {
    display: block;
}

.dock {
    position: fixed;
    z-index: 3;
    left: max(20px, env(safe-area-inset-left));
    bottom: max(20px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: max-content;
    max-width: calc(100vw - 20px);
}

.dock-bar {
    display: flex;
    gap: 6px;
    padding: 6px 7px;
    border-radius: 999px;
}

.tiles {
    display: flex;
    gap: 4px;
}

.tiles + .tiles {
    padding-left: 6px;
    background: linear-gradient(rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.2)) left center / 1px 28px no-repeat;
}

.tile {
    --tint: var(--ink);
    --tint-on: var(--panel-ink);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tile .icon {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--tint);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tile.active {
    background: var(--ink);
    color: var(--panel-ink);
}

.tile.active .icon {
    stroke: var(--tint-on);
}

.tile[data-key="spring"] {
    --tint: #f2a3bb;
    --tint-on: #d5487a;
}

.tile[data-key="summer"] {
    --tint: #93d162;
    --tint-on: #478f27;
}

.tile[data-key="autumn"] {
    --tint: #f0a544;
    --tint-on: #d26f14;
}

.tile[data-key="winter"] {
    --tint: #94cdf2;
    --tint-on: #2a7fc2;
}

.tile[data-key="day"] {
    --tint: #f6cf55;
    --tint-on: #cf9208;
}

.tile[data-key="legend"] {
    --tint: #f5a494;
    --tint-on: #d6493a;
}

.tile[data-key="night"] {
    --tint: #aeb8f6;
    --tint-on: #4852bb;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 0;
    min-width: 100%;
    padding: 14px 18px;
    border-radius: 28px;
}

.row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
}

.name {
    flex: 0 0 62px;
    color: var(--muted);
    font-size: 12px;
}

.group {
    display: flex;
    flex: 1;
    min-width: 0;
    gap: 2px;
    padding: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
}

.group button {
    flex: 1 1 0;
    min-width: 0;
    height: 30px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.group button.active {
    background: var(--ink);
    color: var(--panel-ink);
}

.toggles {
    display: flex;
    flex: 1;
    min-width: 0;
    gap: 6px;
}

.toggles button,
.play {
    flex: 1 1 0;
    min-width: 0;
    height: 34px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.toggles button {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: 7px;
    white-space: nowrap;
}

.toggles button::before {
    content: "";
    flex: 0 0 7px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.28);
}

.toggles button.active {
    color: var(--ink);
}

.toggles button.active::before {
    background: var(--accent);
}

.play {
    flex: 0 0 78px;
    color: var(--ink);
}

.play.active {
    background: var(--ink);
    color: var(--panel-ink);
}

input[type="range"] {
    flex: 1;
    min-width: 0;
    height: 34px;
    margin: 0;
    background: transparent;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: var(--day-track);
}

input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: var(--day-track);
}

input[type="range"]::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
    margin-top: -5px;
    border: 3px solid var(--panel-ink);
    border-radius: 50%;
    background: var(--ink);
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border: 3px solid var(--panel-ink);
    border-radius: 50%;
    background: var(--ink);
}

output {
    flex: 0 0 42px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    text-align: right;
}

.credits {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 3;
    max-width: calc(100vw - 28px);
    padding: 6px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    text-align: right;
}

.credits a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.38);
    text-underline-offset: 3px;
}

body.touring .credits {
    bottom: 6px;
    padding: 4px 11px;
}

.loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d1118;
}

.loading[hidden] {
    display: none;
}

.loading-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: center;
}

.loading-box strong {
    font-size: 22px;
    letter-spacing: -0.01em;
}

.loading-box span {
    color: var(--muted);
}

@media (max-width: 860px), (max-height: 500px) {
    .dock {
        bottom: calc(64px + env(safe-area-inset-bottom));
    }
}

@media (max-height: 480px) {
    .panel {
        gap: 4px;
        padding: 8px 14px;
    }
}

@media (max-width: 640px) {
    .brand {
        left: max(10px, env(safe-area-inset-left));
        top: max(10px, env(safe-area-inset-top));
        gap: 8px;
        padding: 6px 11px 6px 8px;
    }

    .brand-mark {
        height: 27px;
    }

    .brand strong {
        font-size: 14px;
    }

    .brand span {
        display: none;
    }

    .info {
        left: max(10px, env(safe-area-inset-left));
        top: calc(52px + env(safe-area-inset-top));
        width: min(300px, calc(100vw - 20px));
    }

    .about {
        left: max(10px, env(safe-area-inset-left));
        top: calc(52px + env(safe-area-inset-top));
        width: calc(100vw - 20px);
        max-height: calc(100% - 210px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }

    .brand-about {
        display: none;
    }

    .corner {
        right: max(10px, env(safe-area-inset-right));
        top: max(10px, env(safe-area-inset-top));
    }

    .tool {
        min-width: 38px;
        padding: 0 10px;
    }

    .dock {
        left: max(10px, env(safe-area-inset-left));
        right: max(10px, env(safe-area-inset-right));
        width: auto;
        max-width: none;
    }

    .dock-bar {
        gap: 0;
        padding: 5px 4px;
    }

    .tiles {
        flex: 4 1 0;
        gap: 0;
    }

    .tiles + .tiles {
        flex-grow: 2;
        padding-left: 0;
        background: none;
    }

    .tiles.daytime {
        flex-grow: 1;
    }

    .daytime .tile:not(.active) {
        display: none;
    }

    .tile,
    .tile.active {
        flex: 1 1 0;
        gap: 3px;
        width: auto;
        min-width: 0;
        height: 50px;
        border-radius: 0;
        background: transparent;
        color: var(--ink);
        font-size: 10px;
    }

    .tile span {
        white-space: nowrap;
    }

    .tile .icon {
        box-sizing: content-box;
        flex: 0 0 18px;
        width: 18px;
        height: 18px;
        padding: 5px 10px;
        border-radius: 999px;
        transition: background-color 0.15s ease;
    }

    .tile.active .icon {
        background: var(--ink);
    }

    .panel {
        padding: 12px 14px;
        border-radius: 24px;
    }

    .name {
        flex-basis: 54px;
        font-size: 11.5px;
    }

    .group button,
    .toggles button,
    .play {
        padding: 0 4px;
        font-size: 12px;
    }

    .play {
        flex-basis: 66px;
    }

    .credits {
        left: max(10px, env(safe-area-inset-left));
        right: max(10px, env(safe-area-inset-right));
        bottom: max(6px, env(safe-area-inset-bottom));
        padding: 5px 10px;
        font-size: 10.5px;
        text-align: center;
    }
}

.no-ui .corner,
.no-ui .dock,
.no-ui .brand,
.no-ui .about,
.no-ui .info {
    display: none;
}

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

.dock,
.corner {
    transition: opacity 0.35s ease;
}

body.ui-pending .dock,
body.ui-pending .corner {
    visibility: hidden;
    opacity: 0;
}

body.walking .info,
body.walking .about,
body.walking #labels,
body.walking .hover-tip,
body.walking .tilt {
    display: none;
}

body.walking canvas {
    cursor: crosshair;
}

.walk-hint {
    position: fixed;
    z-index: 3;
    left: 50%;
    top: max(64px, calc(env(safe-area-inset-top) + 56px));
    transform: translateX(-50%);
    max-width: calc(100vw - 24px);
    padding: 8px 14px;
    border: 1px solid var(--glass-edge);
    border-radius: 999px;
    background: var(--glass);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
}

.walk-hint[hidden],
.walk-pad[hidden] {
    display: none;
}

.walk-pad {
    position: fixed;
    z-index: 2;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.walk-pad::before,
.walk-knob {
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.walk-pad::before {
    content: "";
    width: 116px;
    height: 116px;
    border: 2px solid rgba(255, 255, 255, 0.55);
    background: rgba(20, 24, 32, 0.22);
}

.walk-knob {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.85);
}

body.touring .brand,
body.touring .dock,
body.touring .info,
body.touring .about,
body.touring #labels,
body.touring .tilt {
    display: none;
}

.tour {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.tour[hidden] {
    display: none;
}

.tour-bar {
    position: absolute;
    left: 0;
    right: 0;
    height: var(--tour-bar);
    background: #000;
}

.tour-bar.top {
    top: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 156px 0 clamp(16px, 3vw, 28px);
}

.tour-progress {
    flex: 1;
    display: flex;
    gap: 3px;
    min-width: 0;
}

.tour-step {
    flex: 1 1 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.24);
    overflow: hidden;
}

.tour-step i {
    display: block;
    height: 100%;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
}

.tour-clock {
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

body.touring .corner {
    top: calc((var(--tour-bar) - 32px) / 2);
}

.tour-bar.bottom {
    bottom: 0;
}

.belka {
    --belka-left: clamp(20px, 5vw, 76px);
    position: absolute;
    left: var(--belka-left);
    bottom: calc(var(--tour-bar) + 30px);
    display: flex;
    align-items: center;
    gap: 0.5em;
    max-width: calc(100vw - 2 * var(--belka-left));
    padding: 0.42em 0.85em 0.46em 0.7em;
    border-left: 8px solid var(--accent);
    background: #f3f5f8;
    color: #10141c;
    font-size: clamp(22px, 2.5vw, 38px);
    font-weight: 800;
    letter-spacing: -0.015em;
    line-height: 1.1;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.45s cubic-bezier(0.7, 0, 0.2, 1);
}

.belka.visible {
    clip-path: inset(0 0 0 0);
}

.belka strong,
.belka span {
    font-weight: inherit;
    white-space: nowrap;
}

.belka span {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.belka span::before {
    content: "";
    flex: 0 0 0.26em;
    width: 0.26em;
    height: 0.26em;
    background: var(--accent);
}

.belka span:empty {
    display: none;
}

.tour-fade {
    position: fixed;
    inset: 0;
    z-index: 2;
    background: #000;
    opacity: 0;
    pointer-events: none;
}

.tour-fade.fading {
    transition: opacity 0.9s ease;
}

@media (max-width: 760px) {
    .belka {
        bottom: calc(var(--tour-bar) + 14px);
        flex-direction: column;
        align-items: flex-start;
        gap: 0.12em;
        font-size: 20px;
    }

    .belka strong,
    .belka span {
        white-space: normal;
    }

    .belka span::before {
        display: none;
    }
}

.label.addr {
    padding: 1px 6px;
    background: rgba(255, 255, 255, 0.85);
    color: #14200a;
    font-size: 11px;
}

.label.addr::after {
    height: 6px;
}
