* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #0D5154;
    --primary-dark: #07393b;
    --secondary-color: #475569;
    --success-color: #1f7a60;
    --warning-color: #b45309;
    --danger-color: #b91c1c;
    --bg-color: #eef4f2;
    --surface-color: #f8fbf9;
    --surface-muted: #e2eeec;
    --text-color: #173234;
    --text-light: #667085;
    --border-color: #d3e0de;
    --border-strong: #adc3c0;
    --shadow: 0 1px 3px 0 rgb(13 81 84 / 0.1), 0 1px 2px -1px rgb(13 81 84 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(13 81 84 / 0.12), 0 4px 6px -4px rgb(13 81 84 / 0.12);
    --radius: 8px;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    background: #e8f0ee;
    color: var(--text-color);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
    padding: 20px;
}

body:not(.legal-page) {
    display: flex;
    align-items: center;
    justify-content: center;
}

a {
    color: var(--primary-dark);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.screen {
    display: none;
    background: var(--surface-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-content {
    padding: 60px 40px;
    text-align: center;
}

.eyebrow {
    color: var(--primary-dark);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    margin-bottom: 14px;
    text-transform: uppercase;
}

.welcome-content > .eyebrow,
.results-content > .eyebrow {
    display: none;
}

.welcome-content h1,
.results-content h1,
.legal-content h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 750;
    line-height: 1.15;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-light);
    font-size: 1.2rem;
    line-height: 1.5;
    margin-bottom: 30px;
}

.description {
    color: var(--text-color);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 auto 30px;
    max-width: 600px;
}

.info {
    background: var(--bg-color);
    border-radius: 8px;
    color: var(--text-color);
    display: block;
    font-size: 0.95rem;
    line-height: 1.8;
    margin-bottom: 30px;
    padding: 20px;
    text-align: center;
}

.legal-note {
    color: var(--text-light);
    font-size: 0.86rem;
    line-height: 1.5;
    margin: 18px auto 0;
    max-width: 560px;
}

.btn {
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    justify-content: center;
    line-height: 1.2;
    min-height: 0;
    padding: 14px 32px;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: normal;
}

.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background: #9aa7a5;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-secondary {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--surface-muted);
    border-color: var(--primary-color);
}

.gender-options {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 30px 0;
}

.gender-btn {
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    padding: 20px;
    width: 140px;
}

.gender-btn span {
    align-items: center;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--primary-dark);
    display: inline-flex;
    font-size: 1.25rem;
    font-weight: 800;
    height: 44px;
    justify-content: center;
    width: 44px;
}

.progress-bar {
    background: var(--border-color);
    height: 6px;
    width: 100%;
}

.progress-fill {
    background: var(--primary-color);
    height: 100%;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 20px 40px 10px;
}

#question-container {
    min-height: 400px;
    padding: 20px 40px 40px;
}

.question-title {
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 30px;
}

.answers-grid {
    display: grid;
    gap: 12px;
}

.answer-option {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1.45;
    padding: 18px 24px;
    text-align: left;
    transition: all 0.2s ease;
}

.answer-option:hover {
    background: var(--surface-muted);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.answer-option.selected {
    background: #dcebea;
    border-color: var(--primary-color);
    box-shadow: none;
    color: var(--primary-color);
    font-weight: 600;
}

.answer-option.red-flag {
    border-color: var(--danger-color);
}

.navigation-buttons {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 0 40px 40px;
}

.results-content {
    padding: 40px;
}

.results-content > .eyebrow,
.results-content > h1 {
    text-align: center;
}

.results-content h1 {
    font-size: 2rem;
    margin-bottom: 30px;
}

.results-section {
    background: var(--bg-color);
    border-radius: 12px;
    margin-bottom: 40px;
    padding: 30px;
}

.results-section h2 {
    color: var(--text-color);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 20px;
}

.score-section {
    background: var(--surface-muted);
    text-align: center;
}

.score-display {
    align-items: center;
    display: flex;
    flex-direction: column;
}

.score-circle {
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    height: 200px;
    justify-content: center;
    margin: 20px auto;
    width: 200px;
}

.score-value {
    color: #f8fbf9;
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
}

.score-max {
    color: rgb(248 251 249 / 0.88);
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 5px;
}

.score-interpretation {
    color: var(--text-color);
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.5;
    margin-top: 20px;
    max-width: none;
}

.results-cta {
    align-items: center;
    background: var(--primary-color);
    border-radius: 12px;
    color: #f8fbf9;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin: 0 0 40px;
    padding: 24px 30px;
}

.results-cta-title {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.35;
    margin-bottom: 5px;
}

.results-cta-text {
    color: rgb(248 251 249 / 0.82);
    font-size: 0.94rem;
    line-height: 1.5;
}

.results-cta-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.results-cta .btn-secondary {
    background: transparent;
    border-color: rgb(248 251 249 / 0.58);
    color: #f8fbf9;
}

.results-cta .btn-secondary:hover {
    background: rgb(255 255 255 / 0.08);
}

.report-section {
    border-left: 5px solid var(--border-strong);
}

.section-important {
    background: #fff8f7;
    border-left-color: var(--danger-color);
}

.section-treatment {
    background: #eef4f2;
    border-left-color: var(--primary-color);
}

.section-modifiable {
    background: #fffbeb;
    border-left-color: var(--warning-color);
}

.section-moderate {
    background: #fbfaf4;
    border-left-color: #ca8a04;
}

.section-wellDone {
    background: #eef7f3;
    border-left-color: var(--success-color);
}

.section-subtitle {
    color: var(--text-light);
    font-size: 0.92rem;
    line-height: 1.5;
    margin: -6px 0 16px;
}

.report-items-list {
    display: grid;
    gap: 12px;
}

.report-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
}

.report-item-header {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 8px;
}

.report-item-category {
    color: var(--text-light);
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1.3;
    text-transform: uppercase;
}

.report-item-score {
    background: var(--surface-muted);
    border-radius: 999px;
    color: var(--text-color);
    flex: 0 0 auto;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 4px 9px;
}

.report-item-question {
    color: var(--text-color);
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.45;
    margin-bottom: 5px;
}

.report-item-answer {
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.45;
    margin-bottom: 10px;
}

.report-item-feedback {
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 650;
    line-height: 1.45;
    margin-bottom: 10px;
    padding: 10px 12px;
}

.report-item-feedback-negative {
    background: #fff1f1;
    color: #7f1d1d;
}

.report-item-feedback-positive {
    background: #edf9f0;
    color: #14532d;
}

.report-item-feedback-moderate {
    background: #fff8e6;
    color: #7c2d12;
}

.report-item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.report-badge {
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 800;
    padding: 4px 9px;
}

.badge-kiro {
    background: #dcebea;
    color: var(--primary-dark);
}

.badge-modifiable {
    background: #fff0cc;
    color: #92400e;
}

.category-breakdown,
.tertile-breakdown {
    display: grid;
    gap: 12px;
}

.category-item,
.tertile-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 15px;
}

.category-header,
.tertile-header {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: 10px;
}

.category-name,
.tertile-name {
    color: var(--text-color);
    font-size: 0.98rem;
    font-weight: 750;
    line-height: 1.35;
}

.category-score,
.tertile-score {
    color: var(--primary-dark);
    font-size: 0.9rem;
    font-weight: 800;
}

.category-bar {
    background: #e8eeec;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}

.category-bar-fill {
    background: var(--primary-color);
    height: 100%;
    transition: width 0.4s ease;
}

.tertile-item {
    border-left: 5px solid var(--border-strong);
}

.tertile-item.tertile-good {
    border-left-color: var(--success-color);
}

.tertile-item.tertile-mid {
    border-left-color: var(--warning-color);
}

.tertile-item.tertile-bad {
    border-left-color: var(--danger-color);
}

.tertile-badges {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tertile-badge {
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 4px 9px;
}

.tertile-badge-good {
    background: #dcfce7;
    color: #166534;
}

.tertile-badge-mid {
    background: #fef3c7;
    color: #92400e;
}

.tertile-badge-bad {
    background: #fee2e2;
    color: #991b1b;
}

.tertile-bar-good {
    background: var(--success-color) !important;
}

.tertile-bar-mid {
    background: var(--warning-color) !important;
}

.tertile-bar-bad {
    background: var(--danger-color) !important;
}

.feedback-list {
    display: grid;
    gap: 12px;
}

.feedback-item {
    align-items: flex-start;
    border-radius: var(--radius);
    display: flex;
    gap: 12px;
    padding: 14px 16px;
}

.feedback-item.feedback-positive {
    background: #edf9f0;
}

.feedback-item.feedback-negative {
    background: #fff1f1;
}

.feedback-icon {
    flex-shrink: 0;
    font-size: 1.2rem;
    margin-top: 2px;
}

.feedback-content {
    flex: 1;
}

.feedback-text {
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 650;
    line-height: 1.45;
}

.feedback-source {
    color: var(--text-light);
    font-size: 0.8rem;
    margin-top: 4px;
}

.user-info-form {
    margin: 0 auto;
    max-width: 440px;
    text-align: left;
}

.form-field {
    margin-bottom: 18px;
}

.form-field label {
    color: var(--text-color);
    display: block;
    font-size: 0.92rem;
    font-weight: 750;
    margin-bottom: 8px;
}

.form-field input {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    padding: 14px 16px;
    transition: border-color 0.2s ease, box-shadow 0.16s ease;
    width: 100%;
}

.form-field input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(15 118 110 / 0.14);
    outline: none;
}

.consent-field {
    align-items: flex-start;
    color: var(--text-light);
    display: flex;
    font-size: 0.88rem;
    gap: 10px;
    line-height: 1.45;
    margin: 6px 0 18px;
}

.consent-field input {
    accent-color: var(--primary-color);
    flex: 0 0 auto;
    height: 18px;
    margin-top: 2px;
    width: 18px;
}

.user-info-form .btn {
    margin-top: 10px;
    width: 100%;
}

.form-error {
    background: #fff1f1;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    color: var(--danger-color);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding: 10px 12px;
}

.legal-page {
    display: block;
}

.legal-container {
    margin: 0 auto;
    max-width: 960px;
    width: 100%;
}

.legal-back {
    display: inline-flex;
    font-size: 0.92rem;
    font-weight: 750;
    margin-bottom: 18px;
}

.legal-content {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 48px;
}

.legal-intro {
    color: var(--text-light);
    font-size: 1rem;
    line-height: 1.65;
    margin-bottom: 28px;
    max-width: 720px;
}

.legal-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.legal-grid article {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px;
}

.legal-grid h2 {
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.legal-grid p,
.legal-callout {
    color: var(--text-light);
    font-size: 0.94rem;
    line-height: 1.6;
}

.legal-callout {
    background: #fff8e6;
    border: 1px solid #f5d58a;
    border-radius: var(--radius);
    color: #65320f;
    margin-top: 18px;
    padding: 16px;
}

@media (max-width: 640px) {
    body {
        padding: 20px;
    }

    .welcome-content h1,
    .results-content h1,
    .legal-content h1 {
        font-size: 2rem;
    }

    .legal-grid {
        grid-template-columns: 1fr;
    }

    #question-container {
        min-height: 350px;
        padding: 20px 24px 30px;
    }

    .question-title {
        font-size: 1.2rem;
    }

    .navigation-buttons {
        flex-direction: column;
        padding: 0 24px 30px;
    }

    .navigation-buttons .btn {
        width: 100%;
    }

    .results-content {
        padding: 24px;
    }

    .results-section {
        padding: 20px;
    }

    .results-cta {
        align-items: stretch;
        flex-direction: column;
    }

    .results-cta-actions {
        justify-content: stretch;
    }

    .results-cta-actions .btn {
        width: 100%;
    }

    .report-item-header {
        align-items: flex-start;
    }

    .score-circle {
        height: 160px;
        width: 160px;
    }

    .score-value {
        font-size: 3rem;
    }
}
