:root {
    color-scheme: light;
    --paper: #f7f7f4;
    --surface: #fff;
    --ink: #20211f;
    --muted: #747670;
    --line: #dedfd9;
    --soft: #eeefe9;
    --accent: #536d5c;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--paper);
    color: var(--ink);
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

.hidden {
    display: none !important;
}

.site-header {
    height: 68px;
    padding: 0 max(24px, calc((100vw - 1120px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.wordmark {
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .15em;
    text-decoration: none;
}

.progress-label,
.eyebrow,
.card-number,
.card-status,
.image-frame figcaption {
    font-size: 11px;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.progress-label {
    color: var(--muted);
    letter-spacing: .02em;
    text-transform: none;
}

.back-button {
    padding: 8px 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.back-button:hover {
    color: var(--ink);
}

.page-shell {
    width: min(100% - 48px, 1000px);
    margin: 0 auto;
    padding: 74px 0 64px;
}

.intro {
    max-width: 560px;
    margin-bottom: 42px;
}

.eyebrow {
    margin: 0 0 14px;
    color: var(--muted);
    font-weight: 600;
}

h1 {
    margin: 0;
    font-size: clamp(32px, 5vw, 48px);
    font-weight: 500;
    letter-spacing: -.045em;
    line-height: 1.1;
}

.challenge-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.challenge-card {
    min-height: 150px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
    text-align: left;
}

button.challenge-card {
    width: 100%;
    cursor: pointer;
}

button.challenge-card.is-complete {
    padding: 0;
    overflow: hidden;
}

button.challenge-card:hover {
    border-color: var(--accent);
    background: #fbfcf9;
}

.challenge-card.is-locked {
    background: transparent;
    color: #999b94;
}

.challenge-card.is-complete {
    background: var(--soft);
    border-color: var(--soft);
}

.card-image {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #eeefe9;
}

.card-details {
    width: 100%;
    min-height: 84px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
}

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

.card-title {
    font-size: 16px;
    font-weight: 500;
}

.card-status {
    color: var(--muted);
    font-size: 10px;
}

.is-open .card-status,
.is-complete .card-status {
    color: var(--accent);
}

.challenge-view {
    position: fixed;
    inset: 68px 0 0;
    z-index: 5;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 12px clamp(16px, 3vw, 40px) 18px;
    background: var(--paper);
    overflow-y: auto;
}

.challenge-view:not(.hidden) {
    display: flex;
    flex-direction: column;
}

.back-button {
    align-self: flex-start;
    flex: 0 0 auto;
    margin: 0 0 6px;
    font-size: 13px;
}

.challenge-heading {
    display: flex;
    flex: 0 0 auto;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin: 0 0 10px;
}

.challenge-heading .eyebrow {
    margin: 0;
}

.challenge-heading h1 {
    font-size: clamp(18px, 2vw, 24px);
    letter-spacing: -.025em;
}

.work-area {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
    align-items: start;
    gap: 16px;
    flex: 0 0 auto;
    height: calc(100vh - 190px);
    min-height: 360px;
}

.image-frame {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.guess-panel {
    width: 100%;
    margin: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
}

.image-frame img {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    object-fit: contain;
    background: #f0f0ec;
}

.image-frame figcaption {
    flex: 0 0 auto;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 10px;
}

.guess-panel-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.guess-panel-heading .eyebrow {
    margin: 0;
}

.guess-panel-heading > span {
    color: var(--muted);
    font-size: 10px;
}

.coordinate-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 16px;
}

.guess-panel label {
    display: block;
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 10px;
}

.guess-panel input {
    width: 100%;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 3px;
    outline: none;
    background: var(--surface);
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.guess-panel input:focus {
    border-color: var(--accent);
}

.submit-button {
    width: 100%;
    min-height: 38px;
    margin-top: 10px;
    border: 1px solid var(--accent);
    border-radius: 3px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 13px;
}

.submit-button:hover {
    background: #43594b;
}

.submit-button:disabled {
    cursor: wait;
    opacity: .65;
}

.form-message {
    min-height: 0;
    margin: 6px 0 0;
    color: #8c4e40;
    font-size: 12px;
    line-height: 1.5;
}

.complete-view {
    max-width: 640px;
    margin: 40px auto;
}

.complete-view > .back-button {
    margin-top: 28px;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    max-width: min(420px, calc(100vw - 48px));
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
    box-shadow: 0 4px 18px #20211f12;
    color: var(--ink);
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity .16s ease, transform .16s ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 720px) {
    .site-header {
        height: 60px;
        padding: 0 20px;
    }

    .page-shell {
        width: calc(100% - 40px);
        padding-top: 48px;
    }

    .challenge-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .challenge-card {
        min-height: 132px;
        padding: 14px;
    }

    .challenge-view {
        inset: 60px 0 0;
        padding: 10px 10px 12px;
    }

    .challenge-heading {
        gap: 4px 10px;
    }

    .work-area {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
        min-height: 0;
    }

    .image-frame {
        height: min(66vh, 680px);
        min-height: 320px;
    }

}

@media (min-width: 721px) and (max-height: 520px) {
    .work-area {
        height: calc(100vh - 150px);
    }

    .image-frame {
        height: calc(100vh - 180px);
    }
}

@media (max-width: 390px) {
    .progress-label {
        font-size: 11px;
    }
}
