:root {
    --bg:       #0d0d10;
    --fg:       #f5f5f7;
    --fg-muted: rgb(245 245 247 / 0.60);
    --surface:  rgb(255 255 255 / 0.06);
    --border:   rgb(255 255 255 / 0.16);
    --scrim:    rgb(13 13 16 / 0.72);
    --accent:   #ffb454;
    --glow:     rgb(255 255 255 / 0.045);
}

html {
    -webkit-text-size-adjust: 100%;
}
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--fg);
}

.menu_button, .close_button {
    /* Reset button-specific UA styles now that these are real <button>s. */
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    /* 44px is the usual minimum comfortable touch target; clamp() keeps it
    from also ballooning to ~96px on a wide desktop viewport (5vw @1920px). */
    width: clamp(44px, 5vw, 56px);
    height: clamp(44px, 5vw, 56px);
}

.menu_button {
    position: fixed;
    top: 0.8em;
    left: 1em;
    z-index: 3;
    transition: opacity 180ms linear;
}

body.menu-open .menu_button {
    opacity: 0;
    pointer-events: none;
}

.menu_button > img, .close_button > img {
    width: clamp(20px, 4vw, 24px);
    transition: transform 150ms ease-out;
}

.close_button > img {
    position: absolute;
    right: 0;
    top: 0;
}

.menu_button:hover > img, .close_button:hover > img {
    transform: scale(1.3);
}



.close_button {
    position: fixed;
    top: 0.8em;
    right: 1em;
    opacity: 0;
    transition: opacity 180ms linear;
    z-index: 3;
}

.github-link {
    position: fixed;
    bottom: 1em;
    right: 1em;
    z-index: 1;
}

.github-link img {
    width: clamp(1.5rem, 3vw, 2rem);
}

body.menu-open .close_button {
    opacity: 1;
}


.menu {
    position: fixed;
    inset: 0;
    /* backdrop-filter alone does nothing over a flat background — it needs
    a translucent surface of its own to actually blur. */
    background: var(--scrim);
    backdrop-filter: blur(.4em);
    -webkit-backdrop-filter: blur(.4em); /* safari */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;

    font-size: clamp(1rem, 2.5vw, 1.25rem);

    visibility: hidden;
    opacity: 0;
    transition: opacity 180ms linear, visibility 0s linear 180ms;
}

body.menu-open .menu {
    visibility: visible;
    opacity: 1;
    transition: opacity 180ms linear, visibility 0s linear 0s;
}

.menu__panel {
    display: flex;
    flex-direction: column;
    gap: 1.1em;
    width: min(24em, 86vw);
    text-align: left;
}

.menu__panel h2 {
    text-align: center;
    font-size: 1.1em;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3em;
}

.field label {
    font-weight: bold;
}

.field__help {
    font-size: 0.55em;
    line-height: 1.4;
    color: var(--fg-muted);
}

.field input, .menu__reset {
    font-size: 1em;
    background-color: transparent;
    border-radius: 0.3em;
    border-width: 0.05em;
    border-style: solid;
    border-color: var(--border);
    color: var(--fg);
    padding: 0.3em 0.5em;
}

.field input {
    width: 5em;
    text-align: center;
}

.menu__reset {
    align-self: flex-start;
    cursor: pointer;
}

.menu__reset:hover {
    background: var(--surface);
}

/* [ − | XX | + ] stepper: three segments sharing one border, rather than a
bare number input with the browser's own tiny up/down spinner. */
.stepper {
    display: inline-flex;
    align-items: stretch;
    width: fit-content;
    border-radius: 0.3em;
    border: solid 0.05em var(--border);
    overflow: hidden; /* clip the buttons' square corners to the wrapper's radius */
}

.stepper__btn {
    /* Reset button-specific UA styles now that this is a real <button>. */
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    width: 2em;
    font-size: 1.1em;
    line-height: 1;
    color: var(--fg);
}

.stepper__btn:hover {
    background: var(--surface);
}

.stepper__btn:active {
    background: var(--border);
}

.stepper .stepper__input {
    width: 3.5em;
    border-width: 0;
    border-left: solid 0.05em var(--border);
    border-right: solid 0.05em var(--border);
    border-radius: 0;
    /* Custom +/- buttons make the native up/down spinner redundant. */
    -moz-appearance: textfield;
}

.stepper .stepper__input::-webkit-inner-spin-button,
.stepper .stepper__input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}


#container {
    display: flex;
    height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, var(--glow), transparent 65%);
    /* The tap surface has no text worth selecting, and this stops a
    double/triple-tap from starting a text selection instead of a tap. */
    -webkit-user-select: none;
    user-select: none;
}

#counter {
    visibility: hidden;
    font-family: Arial, Helvetica, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#container.has-reading #counter {
    visibility: visible;
}

#counter-value {
    font-size: clamp(5rem, 18vw, 8rem);
    font-variant-numeric: tabular-nums; /* keep digit width stable as the value changes */
}

.counter-unit {
    font-size: clamp(1rem, 3vw, 1.5rem);
    letter-spacing: 0.15em;
    color: var(--fg-muted);
}

.counter-color {
    color: var(--fg);
}

.counter-animated-taps {
    animation: blink 0.1s linear;
}

@keyframes blink {
    0% { transform: scale(1);}
    50% { transform: scale(1.05);}
    100% { transform: scale(1);}
}

.counter-timeout-fadeout {
    animation: fade 1s linear;
    color: var(--fg-muted);
}

@keyframes fade {
    from {color: var(--fg);}
}

#counter-message {
    display: flex;
    gap: 0.4em;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    visibility: visible;
    position: absolute;
    text-align: center;
    font-size: clamp(1.1rem, 4.5vw, 1.75rem);
}

#container.has-reading #counter-message {
    visibility: hidden;
}

.key {
    border: solid 0.09em var(--fg);
    border-radius: 0.2em;
    padding: 0.05em 0.1em;
}

.tap-icon {
    width: 1.7em;
}


@media (orientation: portrait) {
    #counter-message {
        flex-direction: column;
        gap: 0.4em;
    }
}

@media (orientation: landscape) {
    #counter-message > img {
        margin-left: -0.3em; /* Kerning... */
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
