/*
 * Mobile-first, no build step. Kept to widely supported CSS (iOS Safari 12+, Chrome/Samsung Internet on Android,
 * Firefox, in-app webviews): no flex `gap`, no nesting, no :has(). Brand colours are placeholders in :root.
 */
:root {
    --brand: #0b2a4a;
    --brand-contrast: #ffffff;
    --accent: #c8102e;
    --accent-contrast: #ffffff;
    --bg: #eef2f6;
    --surface: #ffffff;
    --text: #14202b;
    --muted: #5a6875;
    --border: #c3ccd5;
    --error: #b00020;
    --error-bg: #fdecee;
    --highlight-bg: #fff4d6;
    --radius: 12px;
    --gutter: 16px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

h1,
h2 {
    margin: 0 0 12px;
    line-height: 1.2;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 20px;
}

p {
    margin: 0 0 12px;
}

a {
    color: var(--brand);
}

.muted {
    color: var(--muted);
}

/* Header and page frame; padding respects iPhone notches via safe-area insets. */
.site-header {
    background: var(--brand);
    color: var(--brand-contrast);
    padding: 14px var(--gutter);
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-left: calc(var(--gutter) + env(safe-area-inset-left, 0px));
    padding-right: calc(var(--gutter) + env(safe-area-inset-right, 0px));
}

.site-header__brand {
    color: inherit;
    font-weight: 700;
    font-size: 18px;
    text-decoration: none;
}

.page {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: var(--gutter);
    padding-left: calc(var(--gutter) + env(safe-area-inset-left, 0px));
    padding-right: calc(var(--gutter) + env(safe-area-inset-right, 0px));
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: var(--gutter);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card > :last-child {
    margin-bottom: 0;
}

.hero {
    text-align: center;
}

.hero__label {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.hero__time {
    margin: 0 0 12px;
    color: var(--brand);
    font-size: 56px;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

/* Form */
.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-left: 4px solid var(--error);
    border-radius: 6px;
    background: var(--error-bg);
    color: var(--error);
    font-weight: 600;
}

.alert:focus {
    outline: none;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

/* 16px minimum stops iOS Safari from zooming in on focus. */
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"] {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
}

.field input:focus {
    outline: 3px solid rgba(11, 42, 74, 0.35);
    outline-offset: 1px;
    border-color: var(--brand);
}

.field input[aria-invalid="true"] {
    border-color: var(--error);
}

.field__error {
    margin: 6px 0 0;
    color: var(--error);
    font-size: 15px;
}

.field--check {
    position: relative;
    padding-left: 40px;
    min-height: 28px;
}

.field--check input {
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 28px;
    margin: 0;
    accent-color: var(--brand);
}

.field--check label {
    margin: 0;
    font-weight: 400;
}

.field--check .field__error {
    margin-left: 0;
}

/* Honeypot: off-screen rather than display:none, which some bots skip. */
.hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.button {
    display: block;
    width: 100%;
    min-height: 52px;
    padding: 14px 20px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-contrast);
    font: inherit;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.button:focus {
    outline: 3px solid rgba(200, 16, 46, 0.4);
    outline-offset: 2px;
}

.button[disabled] {
    opacity: 0.6;
    cursor: default;
}

.button--secondary {
    background: var(--brand);
    color: var(--brand-contrast);
}

/* Leaderboard */
.toplist {
    margin: 0;
    padding: 0;
    list-style: none;
}

.toplist__row {
    display: flex;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid var(--bg);
}

.toplist__row:last-child {
    border-bottom: 0;
}

.toplist__row--me {
    border-radius: 8px;
    background: var(--highlight-bg);
    font-weight: 700;
}

.toplist__pos {
    flex: 0 0 2.5em;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.toplist__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toplist__time {
    flex: 0 0 auto;
    margin-left: 12px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.debug {
    overflow: auto;
    font-size: 12px;
    white-space: pre-wrap;
}

@media (min-width: 600px) {
    h1 {
        font-size: 34px;
    }

    .card {
        padding: 28px;
    }
}
