@font-face {
    font-family: "Invitation Montserrat";
    src: url("../fonts/Montserrat-BoldItalic.ttf") format("truetype");
    font-style: italic;
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: Michroma;
    src: url("../fonts/Michroma-Regular.woff2") format("woff2");
    font-display: swap;
}

:root {
    color-scheme: dark;
    scrollbar-width: none;
    font-family: Montserrat, "Segoe UI", sans-serif;
    color: #fff;
    background: #061a4d;
    --cyan: #56c8ff;
    --muted: #e4eeff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; display: grid; place-items: center; }
h1, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button, a, .choices label { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 2px solid #6fe3ff; outline-offset: 3px; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.shell {
    width: 100%;
    container-type: inline-size;
    background: radial-gradient(120% 60% at 50% 55%, #1a57d6 0%, #0b3592 42%, #071f5c 100%);
}
.step {
    position: relative;
    isolation: isolate;
    min-height: 100dvh;
    padding: 82px 7.2% 42px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.step::after, .artwork-step::before {
    content: "";
    position: absolute;
    z-index: -1;
    pointer-events: none;
}
.step::after {
    inset: auto auto 0 0;
    width: 38%;
    height: 88px;
    background: url("../images/race-design-flag.jpg") center / cover;
    transform: scaleX(-1);
    mask-image: linear-gradient(315deg, #000 25%, transparent 72%);
}
.artwork-step::before {
    inset: 0 0 auto auto;
    width: 170px;
    height: 90px;
    background: url("../images/race-design-flag.jpg") center / cover no-repeat;
    mask-image: radial-gradient(ellipse at top right, #000 20%, transparent 73%);
}
.artwork-step {
    background: url("../images/race-design-logo.png") left 16px top 12px / 56px 52px no-repeat;
}
.back {
    position: absolute;
    top: 16px;
    right: 14px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid #c8e1ff80;
    border-radius: 22px;
    background: #071f5cc0;
    font-size: .8125rem;
    font-weight: 600;
}
.race-heading {
    width: fit-content;
    max-width: 100%;
    border-bottom: 2px solid;
    padding: 0 2px 4px;
    font: italic 800 clamp(1.12rem, 6.65cqw, 1.625rem)/1 Montserrat, "Segoe UI", sans-serif;
    text-transform: uppercase;
}
.race-heading span { display: block; }
.step-message, .profile-message, .loading-message {
    margin-top: 14px;
    color: var(--muted);
    font-size: .875rem;
    line-height: 1.4;
}

#home { padding: 0 0 46px; }
.home-background {
    width: 100%;
    height: 119.2cqw;
    object-fit: cover;
    mask-image: linear-gradient(#000 80%, transparent);
}
.event-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    padding-inline: 4.6%;
    margin-top: -3px;
    font: clamp(.6875rem, 3.2cqw, .875rem)/1.35 Michroma, "Segoe UI", sans-serif;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
.event-details > div {
    container-type: inline-size;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    justify-items: center;
    gap: 5px;
    padding-inline: 5px;
}
.event-details > div + div { border-left: 1px solid #c8e1ff73; }
.event-details > div > div {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 3px;
    border-bottom: 1.5px solid;
    letter-spacing: .08em;
}
.event-details p { font-weight: 700; white-space: nowrap; }
.event-details > div:first-child p { font-size: min(.875rem, 2.45vw); font-size: min(.875rem, 5.8cqw); }
.event-details > div + div p:first-of-type { font-size: min(1.125rem, 3.55vw); font-size: min(1.125rem, 8.4cqw); }
.event-details > div + div p:last-of-type {
    font-size: min(.75rem, 2.15vw);
    font-size: min(.75rem, 5.1cqw);
    font-weight: 500;
    line-height: 1.35;
}
#team-form {
    width: min(77%, 300px);
    margin-top: 44px;
    display: grid;
    justify-items: center;
    flex: 1;
    align-content: space-between;
    gap: 30px;
}
fieldset { width: 100%; min-width: 0; padding: 0; margin: 0; border: 0; }
#team-form .choices {
    padding: 4px 16px;
    border: 1.5px solid #5aaaffd9;
    border-radius: 10px;
    background: #0a287899;
    box-shadow: 0 0 16px #3ca0ff73, inset 0 0 14px #3ca0ff40;
}
#team-form label { display: flex; align-items: center; gap: 14px; min-height: 46px; text-align: left; }
#team-form label + label { border-top: 1px solid #78b4ff59; }
#team-form input {
    appearance: none;
    width: 20px;
    height: 20px;
    margin: 0;
    flex: none;
    border: 1.5px solid #dfe9ff;
    border-radius: 4px;
}
#team-form input:checked { background: #38d6ff; border-color: #38d6ff; box-shadow: inset 0 0 0 3px #0b2a78; }

.race-button {
    position: relative;
    isolation: isolate;
    width: min(100%, 300px);
    min-height: 58px;
    border: 0;
    background: transparent;
    font: italic 800 1.5rem/1 Montserrat, "Segoe UI", sans-serif;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.race-button::before, .race-button::after {
    content: "";
    position: absolute;
    transform: skewX(-33deg);
    border-radius: 5px;
    pointer-events: none;
}
.race-button::before {
    z-index: -2;
    inset: 8px 13px 6px;
    border: 2px solid #42caff;
    background:
        repeating-conic-gradient(#d6ebff 0% 25%, #0b2858 0% 50%) 5px 50% / 18px 16px repeat,
        #0a2957;
    background-clip: content-box, padding-box;
    padding: 3px 4px;
    box-shadow: 0 0 9px #18aaff, inset 0 0 7px #368dff;
}
.race-button::after {
    z-index: -1;
    inset: 3px 40px;
    border: 2px solid #ceefff;
    background: linear-gradient(165deg, #081a3d, #112f76);
    box-shadow: 0 0 10px #20baff, inset 0 0 10px #42aaff80;
}
.race-button:not(:disabled):hover::after { background: linear-gradient(165deg, #0d2654, #19429b); }

#profile-form {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 22px;
    text-align: left;
}
#profile-form > label { display: grid; gap: 8px; }
#profile-form > label, #profile-form legend { font-size: .8125rem; font-weight: 700; letter-spacing: .04em; }
#profile-form legend { padding: 0 0 3px; margin-bottom: 14px; border-bottom: 1.5px solid #a0c8ff99; }
#profile-form input:not([type=radio]), select {
    width: 100%;
    min-height: 50px;
    padding: 0 14px;
    border: 1px solid #2f6ff0;
    border-radius: 8px;
    background: #081e5fa6;
    box-shadow: inset 0 0 10px #2f6ff059;
    font-size: .9375rem;
}
select option { background: #0b2a78; }
#race-field { position: relative; }
#race-field select {
    appearance: none;
    height: 50px;
    padding-right: 36px;
    font-weight: 400;
}
#race-field::after {
    content: "";
    position: absolute;
    right: 16px;
    bottom: 22px;
    width: 8px;
    height: 8px;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    pointer-events: none;
}
#profile-form input:not([type=radio]) { text-transform: uppercase; }
#profile-form .choices { display: flex; justify-content: center; gap: 8cqw; }
#profile-form .choices label {
    display: grid;
    place-items: center;
    width: min(39%, 124px);
    min-height: 48px;
    border: 1.5px solid #dfe9ff;
    border-radius: 6px;
    background: #071f5c59;
    font-weight: 800;
}
#profile-form .choices label:has(:checked) {
    border-color: #4aa8ff;
    background: linear-gradient(#1b5cf0, #0b2fa0);
    box-shadow: 0 0 14px #46a0ffb3;
}
#profile-form .choices label:has(:focus-visible) { outline: 2px solid var(--cyan); outline-offset: 3px; }
#profile-form .race-button { align-self: center; margin-top: auto; }

.photo-preview {
    width: min(100%, 300px);
    padding: 8px;
    margin-top: 24px;
    position: relative;
}
.photo-preview::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 4px solid #fff;
    clip-path: polygon(0 0, 9% 0, 9% 9%, 91% 9%, 91% 0, 100% 0, 100% 9%, 91% 9%, 91% 91%, 100% 91%, 100% 100%, 91% 100%, 91% 91%, 9% 91%, 9% 100%, 0 100%, 0 91%, 9% 91%, 9% 9%, 0 9%);
    pointer-events: none;
}
.photo-frame {
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    aspect-ratio: 282 / 330;
    padding: 9px;
    border: 1.5px dashed #47d4ff;
    border-radius: 4px;
}
.photo-frame > * { grid-area: 1 / 1; border-radius: 14px; }
.photo-frame img, .photo-frame video { width: 100%; height: 100%; object-fit: cover; }
video[data-facing=user] { transform: scaleX(-1); }
#photo-placeholder {
    display: grid;
    width: 100%;
    height: 100%;
    align-content: center;
    justify-items: center;
    gap: 12px;
    color: #cfe0ff;
    background: #ffffff12;
    font-size: .8125rem;
}
#photo-placeholder::before {
    content: "";
    width: 86px;
    height: 86px;
    background: radial-gradient(circle at 50% 31%, transparent 15px, #cfe0ff 16px 18px, transparent 19px),
        radial-gradient(ellipse 36px 34px at 50% 100%, transparent 90%, #cfe0ff 93% 98%, transparent);
}
.photo-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    margin-top: 14px;
}
#camera-select { grid-column: 1 / -1; min-height: 40px; font-size: .8125rem; }
#capture, #upload-button {
    min-height: 46px;
    padding: 4px 8px;
    border: 1.5px solid var(--cyan);
    border-radius: 23px;
    background: #0d2f86cc;
    font-size: .8125rem;
    font-weight: 700;
}
#upload-button { border-color: #dcebffd9; background: transparent; }
.photo-tips {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 16px 0 12px;
}
.photo-tips li { display: grid; justify-items: center; gap: 6px; color: var(--muted); font-size: .75rem; }
.photo-tips svg {
    box-sizing: content-box;
    padding: 11px;
    border: 1.5px solid var(--cyan);
    border-radius: 50%;
    background: #0d2f86cc;
}
#photo-status { margin: 8px 0; padding: 8px 12px; border: 1px solid #a0c8ff99; border-radius: 8px; background: #071f5c; font-size: .8125rem; }
#photo-status:empty { display: none; }
#photo .race-button { margin-top: auto; }

#loading { padding-top: 74px; }
.loading-art {
    width: calc(100% / .856);
    height: 116cqw;
    object-fit: cover;
    mask-image: linear-gradient(transparent, #000 14%, #000 80%, transparent);
}
.loading-progress { width: 100%; margin-top: 14px; }
.loading-progress-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: .75rem; font-weight: 700; text-align: left; }
.loading-progress progress { appearance: none; width: 100%; height: 20px; border: 0; border-radius: 10px; overflow: hidden; background: #a0c8ff2e; accent-color: #3ee6ff; }
.loading-progress progress::-webkit-progress-bar { background: #a0c8ff2e; }
.loading-progress progress::-webkit-progress-value { background: linear-gradient(90deg, #3ee6ff, #1e6bff); border-radius: 10px; }
.loading-progress progress::-moz-progress-bar { background: linear-gradient(90deg, #3ee6ff, #1e6bff); border-radius: 10px; }

#result { padding-top: 70px; }
#result .race-heading { font-size: clamp(1rem, 5.9cqw, 1.4375rem); }
.invitation-frame {
    width: min(100%, 308px);
    margin: 18px auto;
    filter: drop-shadow(0 0 10px #45e3ffa6);
}
#invitation {
    display: block;
    width: 100%;
    height: 137cqw;
    object-fit: contain;
    border: 2px solid #45e3ff;
    border-radius: 15px;
    background: #0d3596;
}
.result-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: auto;
}
.result-actions > * {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    padding: 4px;
    border: 1.5px solid #dcebffe6;
    border-radius: 8px;
    background: #071f5c80;
    color: #fff;
    font-size: .8125rem;
    font-weight: 800;
    line-height: 1.15;
    text-decoration: none;
    text-transform: uppercase;
}
#download {
    border-color: #4aa8ff;
    background: linear-gradient(#1b5cf0, #0b2fa0);
    box-shadow: 0 0 14px #46a0ff99;
}
.download-icon { font-size: 1.25rem; }
#result-unavailable { gap: 14px; }
#result-unavailable a { color: #a6e8ff; }

/* Fill the mobile viewport and scale the reference artboard on larger screens. */

@media (min-width: 600px) and (pointer: fine) {
    body { height: 100dvh; overflow: hidden; }
    .shell {
        width: 390px;
        height: 844px;
        zoom: calc(100dvh / 844px);
        overflow-x: hidden;
        overflow-y: auto;
        scrollbar-width: none;
    }
    .step { min-height: 844px; }
    #photo { padding-bottom: 24px; }
}

@media (max-width: 599px), (pointer: coarse) {
    #home {
        display: grid;
        grid-template-rows: minmax(180px, 1fr) auto auto;
        justify-items: center;
        min-height: 0;
        height: 100vh;
        height: 100svh;
        padding: 6px 0 14px;
    }
    .home-background {
        display: block;
        height: 100%;
        min-height: 0;
        object-fit: contain;
        object-position: center bottom;
    }
    #team-form {
        margin-top: clamp(12px, 2.5svh, 24px);
        gap: clamp(12px, 2svh, 20px);
    }
    #profile, #photo {
        min-height: 100svh;
        padding-top: clamp(65px, 10svh, 82px);
        padding-bottom: clamp(14px, 3svh, 24px);
    }
    #profile-form { gap: clamp(10px, 2svh, 18px); }
    #profile-form input:not([type=radio]), #race-field select { font-size: 1rem; }
    #photo .step-message { margin-top: 10px; }
    .photo-preview {
        width: min(100%, 300px, 32svh);
        margin-top: 14px;
    }
    .photo-actions { margin-top: 12px; }
    #camera-select { height: 40px; }
    .photo-tips { margin: 10px 0; }
    .photo-tips svg { padding: 7px; }
    .loading-art { height: min(116cqw, 55svh); }
    #result {
        min-height: 100svh;
        padding-bottom: 54px;
    }
    .invitation-frame { margin-block: 12px; }
    #invitation { height: min(137cqw, max(180px, calc(100svh - 285px))); }
}

@media (max-height: 500px) and (pointer: coarse), (max-height: 500px) and (max-width: 599px) {
    #home { height: auto; }
    .home-background { height: auto; max-height: 320px; }
}
