:root {
    --background: #e8e8e6;
    --surface: #f5f5f3;
    --ink: #171717;
    --muted: #767674;
    --line: #c9c9c6;
    --gray-dot: #989896;
    --black-dot: #171717;
}

* {
    box-sizing: border-box;
}

body {
    display: grid;
    place-items: center;
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    color: var(--ink);
    background: var(--background);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    width: min(100% - 40px, 1120px);
    min-height: 100vh;
    margin: 0 auto;
}

.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    align-items: center;
}

.screen.active {
    display: flex;
}

#intro-screen {
    position: relative;
    max-width: 620px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    padding: 32px 0;
    text-align: center;
}

body.test-mode {
    height: 100vh;
    overflow: hidden;
}

body.test-mode .app-shell {
    height: 100vh;
    overflow: hidden;
}

.brand-mark {
    display: grid;
    grid-template-columns: repeat(2, 10px);
    gap: 5px;
    width: 25px;
    margin-bottom: 32px;
}

.brand-mark span {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ink);
}

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(3) {
    background: var(--gray-dot);
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 24px;
    font-size: clamp(56px, 10vw, 106px);
    font-weight: 700;
    letter-spacing: -0.08em;
    line-height: 0.86;
}

h1 em {
    font-style: normal;
    font-weight: 400;
}

.intro-copy {
    max-width: 410px;
    margin-bottom: 38px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.65;
}

.profile-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    width: 100%;
    max-width: 470px;
    text-align: left;
}

label {
    display: flex;
    justify-content: space-between;
    margin-bottom: -2px;
    font-size: 12px;
    font-weight: 700;
}

label span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 400;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 13px 12px;
    color: var(--ink);
    background: transparent;
    outline: none;
}

input:focus {
    border-color: var(--ink);
}

.profile-form .primary-button {
    grid-column: 1 / -1;
    margin-top: 14px;
}

.primary-button,
.secondary-button {
    border: 1px solid var(--ink);
    border-radius: 0;
    padding: 14px 18px;
    color: var(--surface);
    background: var(--ink);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.primary-button:hover,
.primary-button:focus-visible {
    color: var(--ink);
    background: transparent;
}

.primary-button:active {
    transform: translateY(1px);
}

.primary-button span {
    margin-left: 12px;
    font-size: 18px;
    line-height: 0;
}

.test-facts {
    display: flex;
    gap: 36px;
    justify-content: center;
    width: fit-content;
    margin: 32px auto;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.test-facts div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.test-facts strong {
    font-size: 20px;
}

.test-facts span {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.instructions {
    width: 100%;
    max-width: 470px;
    margin-top: 34px;
    border-top: 1px solid var(--line);
}

.instructions h2 {
    margin: 0;
    padding: 16px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.instructions-content {
    padding: 0 0 8px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.instructions-content ul {
    display: grid;
    gap: 8px;
    margin: 18px 0;
    padding: 0;
    list-style: none;
}

.instructions-content li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dot {
    display: inline-block;
    width: 13px;
    height: 13px;
    border-radius: 50%;
}

.dot-empty {
    border: 1px solid var(--line);
}

.dot-gray {
    background: var(--gray-dot);
}

.dot-black {
    background: var(--black-dot);
}

#test-screen {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.test-header {
    display: flex;
    justify-content: center;
    align-items: end;
    gap: clamp(32px, 8vw, 100px);
    width: 100%;
    margin-bottom: 56px;
}

.item-label {
    margin: 0;
    font-size: 14px;
}

.item-label strong {
    font-size: 24px;
}

.item-label span,
.progress-wrap > span {
    color: var(--muted);
    font-size: 11px;
}

.progress-wrap {
    width: 180px;
}

.progress-wrap > span {
    display: block;
    margin-bottom: 8px;
    text-align: right;
}

.progress-track {
    height: 3px;
    background: var(--line);
}

.progress-bar {
    width: 0;
    height: 100%;
    background: var(--ink);
    transition: width 300ms ease;
}

.phase-label {
    min-height: 18px;
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-align: center;
    text-transform: uppercase;
}

.grid-stage {
    position: relative;
    width: min(25vw, 220px);
    min-height: min(25vw, 220px);
    margin: 0 auto;
}

.grid-panel {
    position: absolute;
    inset: 0;
    width: 100%;
}

.grid-panel.hidden-panel {
    visibility: hidden;
}

.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--line);
    background: rgba(245, 245, 243, 0.48);
}

.cell {
    display: grid;
    place-items: center;
    min-width: 0;
    border: 0;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: transparent;
}

.cell:nth-child(5n) {
    border-right: 0;
}

.cell:nth-last-child(-n + 5) {
    border-bottom: 0;
}

.cell::after {
    width: 75%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: transparent;
    content: "";
}

.cell.gray::after {
    background: var(--gray-dot);
}

.cell.black::after {
    background: var(--black-dot);
}

.answer-panel .cell {
    cursor: pointer;
}

.answer-panel .cell:hover {
    background: rgba(0, 0, 0, 0.05);
}

.answer-panel {
    outline: 1px solid transparent;
    outline-offset: 7px;
}

.answer-panel.ready {
    outline-color: var(--line);
}

.test-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
    margin-top: 56px;
    text-align: center;
}

.helper-text {
    max-width: 320px;
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.submit-button:disabled {
    cursor: not-allowed;
    opacity: 0.35;
}

#result-screen {
    max-width: 620px;
    flex-direction: column;
    justify-content: center;
    margin: 0 auto;
    text-align: center;
}

h2 {
    margin-bottom: 44px;
    font-size: clamp(48px, 8vw, 88px);
    letter-spacing: -0.07em;
    line-height: 0.9;
}

.score-display {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.score-number {
    font-size: 96px;
    letter-spacing: -0.09em;
    line-height: 0.9;
}

.score-caption {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.result-copy {
    max-width: 380px;
    margin: 24px 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.result-meta {
    display: flex;
    justify-content: space-between;
    max-width: 380px;
    margin-bottom: 38px;
    font-size: 12px;
    font-weight: 700;
}

#result-status {
    color: var(--muted);
    font-weight: 400;
}

.secondary-button {
    align-self: center;
    color: var(--ink);
    background: transparent;
}

.secondary-button:hover,
.secondary-button:focus-visible {
    color: var(--surface);
    background: var(--ink);
}

@media (max-width: 700px) {
    .app-shell {
        width: min(100% - 32px, 540px);
    }

    #intro-screen {
        min-height: 100vh;
        padding: 28px 0 40px;
    }

    .brand-mark {
        margin-bottom: 24px;
    }

    h1 {
        margin-bottom: 18px;
        font-size: clamp(48px, 15vw, 78px);
    }

    .instructions {
        margin-top: 20px;
    }

    .instructions-content {
        font-size: 12px;
    }

    .test-facts {
        gap: 20px;
        margin: 24px auto;
    }

    .test-facts span {
        font-size: 9px;
    }

    .profile-form {
        gap: 8px 12px;
    }

    #test-screen {
        padding: 24px 0;
    }

    .test-header {
        align-items: center;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 28px;
    }

    .test-header > div {
        text-align: center;
    }

    .progress-wrap {
        width: min(180px, 70vw);
    }

    .progress-wrap > span {
        text-align: center;
    }

    .phase-label {
        margin-bottom: 16px;
    }

    .grid-stage {
        width: min(48vw, 220px);
        min-height: min(48vw, 220px);
    }

    .test-footer {
        width: 100%;
        margin-top: 28px;
    }

    .submit-button {
        width: 100%;
        max-width: 320px;
    }

    #result-screen {
        padding: 24px 0;
    }

    .result-meta {
        width: 100%;
        max-width: 380px;
        gap: 16px;
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 430px) {
    .profile-form {
        grid-template-columns: 1fr;
    }

    .profile-form .primary-button {
        grid-column: auto;
    }

}
