:root {
    color-scheme: light;
    --paper: #f4f1eb;
    --ink: #191b1d;
    --stage: #202327;
    --line: #d8d3ca;
    --muted: #74716b;
    --fire: #d46a25;
    --hold-progress: 0;
    --radius: 24px;
    font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    background: var(--paper);
    color: var(--ink);
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.studio {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    min-height: 100svh;
    padding: 18px;
    gap: 14px;
}

.studio-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    gap: 18px;
    padding: 0 4px;
}

.identity {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 11px;
}

.identity-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--ink);
    color: var(--paper);
    font: 700 18px/1 "STKaiti", "KaiTi", serif;
}

.identity > span:last-child {
    display: grid;
    gap: 2px;
}

.identity strong {
    overflow: hidden;
    font-size: 15px;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: .02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.identity small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .1em;
}

.home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 15px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.home-link:hover {
    border-color: #b7b0a5;
    background: #ebe7df;
}

.home-link:active {
    transform: scale(.97);
}

.viewer {
    position: relative;
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius);
    outline: none;
    background:
        radial-gradient(circle at 50% 48%, rgba(255, 255, 255, .09), transparent 34%),
        linear-gradient(150deg, #2c3034 0%, var(--stage) 52%, #181a1d 100%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .46) inset,
        0 22px 55px rgba(39, 35, 29, .14);
    cursor: grab;
    touch-action: none;
}

.viewer::before {
    content: "";
    position: absolute;
    z-index: 1;
    left: 9%;
    right: 9%;
    bottom: 16%;
    height: 1px;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .18), transparent);
}

.viewer::after {
    content: "";
    position: absolute;
    z-index: 1;
    left: 50%;
    bottom: 12%;
    width: min(66vw, 760px);
    height: min(12vw, 120px);
    border: 1px solid rgba(255, 255, 255, .12);
    border-bottom-color: transparent;
    border-radius: 50% 50% 0 0;
    pointer-events: none;
    transform: translateX(-50%);
}

.viewer:focus-visible {
    box-shadow:
        0 0 0 3px var(--paper),
        0 0 0 5px var(--fire),
        0 22px 55px rgba(39, 35, 29, .14);
}

.viewer.is-dragging {
    cursor: grabbing;
}

#bikeCanvas {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
}

.viewer-title {
    position: absolute;
    z-index: 3;
    top: 30px;
    left: 32px;
    display: grid;
    pointer-events: none;
}

.ridden-mark {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    overflow: hidden;
    min-height: 27px;
    border: 1px solid rgba(222, 151, 91, .58);
    border-radius: 4px;
    color: #f2c79f;
    background: rgba(10, 12, 14, .58);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    backdrop-filter: blur(12px);
}

.ridden-mark b,
.ridden-mark i {
    display: grid;
    min-height: 27px;
    place-items: center;
    font: 700 11px/1 "PingFang SC", "Microsoft YaHei", sans-serif;
    letter-spacing: .13em;
}

.ridden-mark b {
    padding: 0 11px;
}

.ridden-mark i {
    min-width: 34px;
    color: #1f1a16;
    background: #d99557;
    font-style: normal;
    letter-spacing: .05em;
}

.viewer-title small {
    margin-top: 12px;
    color: rgba(255, 255, 255, .56);
    font-size: 10px;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: .17em;
}

.viewer-title strong {
    margin-top: 3px;
    color: #f4f1eb;
    font-family: "STSong", "Songti SC", serif;
    font-size: clamp(26px, 3.6vw, 48px);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.04em;
}

.load-state {
    position: absolute;
    z-index: 5;
    top: 50%;
    left: 50%;
    display: grid;
    width: min(260px, 62vw);
    gap: 9px;
    color: #f4f1eb;
    text-align: center;
    transform: translate(-50%, -50%);
    transition: opacity 300ms ease, visibility 300ms ease;
}

.load-state span {
    font-size: 30px;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.04em;
}

.load-state small {
    color: rgba(255, 255, 255, .6);
    font-size: 11px;
    letter-spacing: .08em;
}

.load-track {
    width: 100%;
    height: 2px;
    overflow: hidden;
    background: rgba(255, 255, 255, .12);
}

.load-track i {
    display: block;
    width: 0;
    height: 100%;
    background: var(--fire);
    transition: width 180ms ease;
}

body.is-ready .load-state {
    visibility: hidden;
    opacity: 0;
}

.control-bar {
    position: absolute;
    z-index: 4;
    left: 50%;
    bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(480px, calc(100% - 40px));
    min-height: 64px;
    padding: 9px 10px 9px 20px;
    gap: 18px;
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 18px;
    background: rgba(18, 20, 22, .78);
    box-shadow: 0 12px 36px rgba(0, 0, 0, .18);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    cursor: default;
    transform: translateX(-50%);
}

.control-bar p {
    display: grid;
    min-width: 0;
    margin: 0;
    gap: 2px;
}

.control-bar strong {
    color: #f4f1eb;
    font-size: 13px;
    font-weight: 650;
}

.control-bar p span {
    color: rgba(255, 255, 255, .5);
    font-size: 10px;
    white-space: nowrap;
}

.ignite {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 108px;
    min-height: 46px;
    padding: 0 18px;
    gap: 9px;
    border: 0;
    border-radius: 12px;
    background: #eee9e0;
    color: #222427;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 180ms ease, color 180ms ease, transform 180ms ease, opacity 180ms ease;
    -webkit-touch-callout: none;
}

.hold-progress {
    position: absolute;
    inset: -3px;
    padding: 2px;
    border-radius: 15px;
    opacity: 0;
    pointer-events: none;
    background: conic-gradient(var(--fire) calc(var(--hold-progress) * 1turn), transparent 0);
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    transition: opacity 160ms ease;
}

.ignite i {
    position: relative;
    width: 13px;
    height: 13px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.ignite i::after {
    content: "";
    position: absolute;
    top: -5px;
    left: 50%;
    width: 2px;
    height: 7px;
    border: 2px solid #eee9e0;
    border-top: 0;
    border-bottom: 0;
    background: currentColor;
    transform: translateX(-50%);
}

.ignite:hover:not(:disabled) {
    background: #fffaf2;
}

.ignite:active:not(:disabled) {
    transform: scale(.97);
}

.ignite:disabled {
    opacity: .38;
    cursor: wait;
}

body.is-igniting .ignite {
    background: var(--fire);
    color: #fff8f0;
}

body.is-holding .ignite {
    color: #fff8f0;
    background: #302821;
    animation: holdButtonCrank .34s ease-in-out infinite;
}

body.is-holding #bikeCanvas {
    animation: holdBikeCrank .34s steps(2, end) infinite;
}

body.is-holding .viewer::before {
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(212, 106, 37, .82), transparent);
    animation: holdGroundPulse .34s ease-in-out infinite;
}

body.is-holding .viewer::after {
    border-color: rgba(212, 106, 37, .46);
    border-bottom-color: transparent;
}

body.is-hold-pulse .viewer {
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .46) inset,
        0 0 0 1px rgba(212, 106, 37, .56),
        0 25px 78px rgba(126, 54, 14, .3);
}

body.is-holding .hold-progress,
body.is-routing-next .hold-progress {
    opacity: 1;
}

body.is-routing-next .ignite {
    color: #fff8f0;
    background: var(--fire);
}

body.is-routing-next .viewer {
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .46) inset,
        0 0 0 1px rgba(212, 106, 37, .4),
        0 24px 74px rgba(104, 47, 14, .26);
}

body.is-igniting .ignite i::after {
    border-color: var(--fire);
}

body.is-igniting .viewer {
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .46) inset,
        0 0 0 1px rgba(212, 106, 37, .3),
        0 22px 70px rgba(104, 47, 14, .2);
}

@keyframes holdBikeCrank {
    0%, 100% {
        filter: brightness(1);
        transform: translate3d(0, 0, 0);
    }
    45% {
        filter: brightness(1.08) saturate(1.08);
        transform: translate3d(.8px, -1px, 0);
    }
}

@keyframes holdGroundPulse {
    0%, 100% {
        opacity: .38;
        transform: scaleX(.76);
    }
    45% {
        opacity: 1;
        transform: scaleX(1);
    }
}

@keyframes holdButtonCrank {
    0%, 100% {
        transform: scale(.98);
        box-shadow: 0 0 0 rgba(212, 106, 37, 0);
    }
    45% {
        transform: scale(1.02);
        box-shadow: 0 0 22px rgba(212, 106, 37, .24);
    }
}

.live-status {
    position: absolute;
    overflow: hidden;
    width: 1px;
    height: 1px;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

body.is-load-error .load-state {
    color: #ffd9c0;
}

body.is-load-error .load-track i {
    background: #d98d60;
}

@media (max-width: 680px) {
    .studio {
        padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
        gap: 10px;
    }

    .studio-header {
        min-height: 44px;
        padding: 0 2px;
    }

    .identity-mark {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }

    .identity strong {
        max-width: 42vw;
        font-size: 14px;
    }

    .identity small {
        font-size: 9px;
    }

    .home-link {
        min-height: 36px;
        padding: 0 12px;
        font-size: 12px;
    }

    .viewer {
        border-radius: 18px;
    }

    .viewer-title {
        top: 22px;
        left: 20px;
    }

    .ridden-mark b,
    .ridden-mark i {
        min-height: 24px;
        font-size: 10px;
    }

    .ridden-mark b {
        padding: 0 9px;
    }

    .ridden-mark i {
        min-width: 31px;
    }

    .viewer-title small {
        margin-top: 9px;
    }

    .viewer-title strong {
        font-size: 30px;
    }

    .control-bar {
        bottom: 14px;
        width: calc(100% - 28px);
        min-height: 58px;
        padding: 8px 8px 8px 14px;
        gap: 10px;
        border-radius: 15px;
    }

    .control-bar p span {
        overflow: hidden;
        max-width: 36vw;
        text-overflow: ellipsis;
    }

    .ignite {
        min-width: 92px;
        min-height: 42px;
        padding: 0 14px;
        font-size: 13px;
    }

    .viewer::after {
        bottom: 14%;
        width: 82vw;
        height: 21vw;
    }
}

@media (max-height: 540px) and (orientation: landscape) {
    .studio {
        grid-template-rows: 42px minmax(0, 1fr);
        padding: 8px 10px 10px;
        gap: 6px;
    }

    .identity-mark {
        width: 32px;
        height: 32px;
    }

    .viewer-title {
        top: 16px;
        left: 18px;
    }

    .viewer-title strong {
        font-size: 27px;
    }

    .control-bar {
        right: 14px;
        bottom: 12px;
        left: auto;
        width: 360px;
        min-height: 54px;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
