:root {
    color-scheme: dark;
    background: #111;
    color: #eee;
    font-family: system-ui, sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 280px;
    min-height: 100vh;
    margin: 0;
    background: #111;
}

button {
    font: inherit;
}

.app {
    display: flex;
    width: min(100% - 32px, 400px);
    min-height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    padding: 28px 0;
}

h1 {
    margin: 0 0 24px;
    font-size: 20px;
    font-weight: 550;
}

.units {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.units button {
    min-width: 58px;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid #393939;
    border-radius: 4px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
}

.units button[aria-pressed="true"] {
    border-color: #eee;
    color: #fff;
}

.units button:focus-visible,
.start-button:focus-visible {
    outline: 2px solid #eee;
    outline-offset: 3px;
}

.speed-section {
    width: min(100%, 340px);
    text-align: center;
}

.dial {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
}

.dial-face {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.dial-outline {
    fill: none;
    stroke: #333;
    stroke-width: 1.5;
}

.dial-arc {
    fill: none;
    stroke: #777;
    stroke-width: 1.5;
}

.dial-mark {
    stroke: #888;
    stroke-width: 1;
}

.dial-mark.major {
    stroke: #ddd;
    stroke-width: 1.5;
}

.dial-label {
    fill: #aaa;
    font-family: system-ui, sans-serif;
    font-size: 10px;
    text-anchor: middle;
    dominant-baseline: middle;
}

.needle {
    transform: rotate(-135deg);
    transform-origin: 150px 150px;
    transition: transform 400ms ease-out;
}

.needle line {
    stroke: #e05a46;
    stroke-linecap: round;
    stroke-width: 2;
}

.needle circle {
    fill: #e05a46;
}

.dial-hub {
    fill: #eee;
}

.speed-readout {
    position: absolute;
    top: 37%;
    left: 50%;
    display: flex;
    align-items: baseline;
    gap: 7px;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.speed-value {
    font-size: clamp(36px, 10vw, 44px);
    font-weight: 400;
    letter-spacing: -0.07em;
    line-height: 1;
}

.speed-unit {
    color: #aaa;
    font-size: 14px;
}

.scale-label {
    margin: -2px 0 0;
    color: #999;
    font-size: 12px;
}

.acceleration-section {
    width: min(100%, 320px);
    margin-top: 34px;
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 13px;
}

.section-heading h2 {
    margin: 0;
    color: #ccc;
    font-size: 14px;
    font-weight: 500;
}

.section-heading output {
    color: #eee;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.acceleration-scale {
    position: relative;
    height: 16px;
}

.scale-track {
    position: absolute;
    top: 7px;
    right: 0;
    left: 0;
    height: 2px;
    background: #555;
}

.scale-marker {
    position: absolute;
    z-index: 1;
    top: 3px;
    left: 0;
    width: 10px;
    height: 10px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: #e05a46;
}

.scale-tick {
    position: absolute;
    top: 4px;
    width: 1px;
    height: 8px;
    background: #aaa;
}

.tick-start {
    left: 0;
}

.tick-middle {
    left: 50%;
}

.tick-end {
    right: 0;
}

.scale-values {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    color: #888;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.start-button {
    min-width: 96px;
    min-height: 42px;
    margin-top: 30px;
    padding: 0 20px;
    border: 1px solid #555;
    border-radius: 4px;
    background: transparent;
    color: #eee;
    cursor: pointer;
}

.start-button:disabled {
    color: #888;
    cursor: default;
}

.status {
    min-height: 18px;
    margin: 12px 0 0;
    color: #888;
    font-size: 12px;
    text-align: center;
}

@media (max-height: 720px) {
    .app {
        min-height: auto;
        padding: 18px 0;
    }

    h1 {
        margin-bottom: 14px;
    }

    .units {
        margin-bottom: 14px;
    }

    .speed-section {
        width: min(72vw, 270px);
    }

    .acceleration-section {
        margin-top: 20px;
    }

    .start-button {
        margin-top: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .needle {
        transition: none;
    }
}
