:root {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --card-bg: #ffffff;
    --primary-color: #2563eb;
    /* High contrast blue */
    --primary-hover: #1d4ed8;
    --border-color: #cbd5e1;
    --text-muted: #64748b;
    --focus-ring: #93c5fd;
    --success-bg: #dcfce7;
    --success-text: #166534;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --text-color: #f1f5f9;
        --card-bg: #1e293b;
        --primary-color: #60a5fa;
        /* Lighter blue for dark mode */
        --primary-hover: #93c5fd;
        --border-color: #334155;
        --text-muted: #94a3b8;
    }
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 112.5%;
    /* 18px base text for readability */
}

/* Container */
.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

/* Header */
.header {
    text-align: left;
    margin-bottom: 3rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.description {
    font-size: 1rem;
    color: var(--text-color);
}

/* Form Sections */
.category-section {
    margin-bottom: 3rem;
}

.category-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-weight: 600;
}

fieldset {
    border: none;
    margin: 0;
    padding: 0;
}

.question-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

legend {
    display: block;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-color);
    width: 100%;
}

/* Rating Options */
.rating-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.radio-option {
    flex: 1;
    min-width: 80px;
    position: relative;
    cursor: pointer;
}

/* Hide native radio input securely */
.radio-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-label {
    display: block;
    padding: 0.75rem 1rem;
    text-align: center;
    background-color: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    user-select: none;
}

/* Focus and Checked States */
.radio-option input[type="radio"]:focus-visible+.radio-label {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.radio-option input[type="radio"]:checked+.radio-label {
    background-color: var(--primary-color);
    color: #fff;
    /* Always white text on primary color background */
    border-color: var(--primary-color);
}

.radio-option:hover .radio-label {
    border-color: var(--primary-color);
    background-color: var(--card-bg);
    /* Use card bg on hover if not checked */
}

/* Hover on checked shouldn't change bg to card-bg */
.radio-option input[type="radio"]:checked:hover+.radio-label {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Button */
.btn-primary {
    display: block;
    width: 100%;
    padding: 1rem 2rem;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 2rem;
}

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

.btn-primary:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

.btn-secondary {
    display: block;
    margin: 2rem auto 0;
    padding: 0.8rem 2rem;
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

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

/* Results */
.hidden {
    display: none;
}

.results-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 3rem;
    border: 2px solid var(--primary-color);
    text-align: center;
}

.results-container h2 {
    margin-bottom: 2rem;
    font-size: 2rem;
    color: var(--text-color);
}

.scores-grid {
    display: grid;
    gap: 2rem;
}

.score-card {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.score-label {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.score-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.score-value-sm {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color);
}

.score-max {
    font-size: 1rem;
    color: var(--text-muted);
}

.subscales-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 600px) {
    .rating-options {
        flex-direction: column;
        gap: 0.5rem;
    }

    .radio-label {
        text-align: left;
        padding: 1rem;
    }
}
