:root {
    --bg: #f9f9f9;
    --ink: #333;
    --muted: #555;
    /* darker than the original #4caf50 so white label text clears WCAG AA */
    --accent: #388e3c;
}

* {
    box-sizing: border-box;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background-color: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    margin: 0;
    padding: 24px 20px 48px;
}

.page {
    max-width: 660px;
    margin: 0 auto;
}

h1 {
    font-size: clamp(1.6rem, 7vw, 2.5rem);
    text-align: center;
    margin: 0 0 8px;
}

.intro {
    text-align: center;
    color: var(--muted);
    margin: 0 0 32px;
}

/* nowrap keeps all three boxes on one line, however narrow the screen */
.triangle {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: clamp(8px, 3vw, 20px);
    margin: 0 0 32px;
}

.option {
    flex: 1 1 0;
    min-width: 0;
    max-width: 120px;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: inherit;
    font-size: clamp(0.95rem, 4vw, 1.2rem);
    font-weight: bold;
    color: inherit;
    background-color: #fff;
    border: 2px solid var(--ink);
    border-radius: 10px;
    cursor: pointer;
}

/* Transitions switch on only after the first paint, so landing straight on
   /cheap-fast/ shows its two boxes already lit rather than animating in. */
.ready .option {
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* hover only where hovering is real, so it doesn't stick after a tap */
@media (hover: hover) {
    .option:hover {
        background-color: #eee;
    }
}

.option:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.option.selected {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Narrow screens wrap the message over several lines, where a ragged centre is
   hard to read. Wide screens fit it in one or two, where centred looks better. */
#result {
    text-align: left;
    font-size: 1.1rem;
    color: var(--muted);
    min-height: 3em;
    margin: 0;
}

@media (min-width: 640px) {
    #result {
        text-align: center;
    }
}

/* Visitor odometer. Stays hidden unless /api/hits answers, so the page is
   unaffected when the KV binding is missing. */
/* display: flex would otherwise beat the hidden attribute's UA display: none */
.counter[hidden] {
    display: none;
}

.counter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 56px;
}

.odometer {
    display: inline-flex;
    gap: 3px;
    padding: 6px;
    background: #1b1b1b;
    border-radius: 5px;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.7);
}

.digit {
    width: 0.8em;
    height: 1.35em;
    overflow: hidden;
    background: linear-gradient(#3d3d3d, #202020);
    border-radius: 2px;
    font-family: ui-monospace, "Courier New", monospace;
    font-size: clamp(1.15rem, 5vw, 1.5rem);
    color: #f4f4f4;
    text-align: center;
}

.strip {
    display: block;
    transition: transform 1.1s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.strip > span {
    display: block;
    height: 1.35em;
    line-height: 1.35em;
}

.counter-label {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
}

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

#result strong {
    color: var(--ink);
}
