:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1f2937;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border-color: #374151;
    --accent: #9B4F96;
    --accent-hover: #b366ad;

    --bi-blue: #0038A8;
    --bi-lavender: #9B4F96;
    --bi-pink: #D60270;

    --focus-ring: 0 0 0 3px rgba(155, 79, 150, 0.5);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover,
a:focus {
    text-decoration: underline;
    color: var(--accent-hover);
}

a:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

header {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--bi-blue), var(--bi-lavender), var(--bi-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

main {
    flex: 1;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.intro {
    background-color: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.intro p {
    margin: 0;
}

.question-block {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.question-block h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.question-text {
    margin: 0 0 1rem 0;
    color: var(--text-secondary);
}

.time-periods {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.time-period {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.time-period label {
    font-weight: 600;
    display: block;
}

.time-desc {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.875rem;
}

select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

select:hover {
    border-color: var(--accent);
}

select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.submit-btn {
    display: block;
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--bi-blue), var(--bi-lavender), var(--bi-pink));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    margin-top: 1rem;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 79, 150, 0.4);
}

.submit-btn:focus {
    outline: none;
    box-shadow: var(--focus-ring);
}

.submit-btn:active {
    transform: translateY(0);
}

#results-section {
    animation: fadeIn 0.3s ease;
}

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

.results-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.results-header h2 {
    margin: 0;
    flex: 1;
}

.copy-btn,
.retake-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 2px solid var(--accent);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.copy-btn {
    background-color: var(--accent);
    color: white;
}

.copy-btn:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.retake-btn {
    background-color: transparent;
    color: var(--accent);
}

.retake-btn:hover {
    background-color: var(--accent);
    color: white;
}

.copy-btn:focus,
.retake-btn:focus {
    outline: none;
    box-shadow: var(--focus-ring);
}

.scale-legend {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.scale-legend h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
}

.legend-bar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.875rem;
}

.legend-gradient {
    height: 1.5rem;
    border-radius: 4px;
    background: linear-gradient(in oklch to right, var(--bi-blue), var(--bi-lavender), var(--bi-pink));
}

.legend-descriptions {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-descriptions span:nth-child(2) {
    text-align: center;
}

.legend-descriptions span:last-child {
    text-align: right;
}

.legend-num {
    display: none;
}

.results-table-container {
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    table-layout: fixed;
}

.results-table colgroup col:first-child {
    width: 40%;
}

.results-table colgroup col {
    width: 20%;
}

.results-table th,
.results-table td {
    padding: 0.75rem 1rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.results-table thead th {
    background-color: var(--bg-secondary);
    font-weight: 600;
}

.results-table th[scope="row"] {
    text-align: left;
    background-color: var(--bg-secondary);
    font-weight: 600;
}

.results-table tbody td {
    font-weight: 600;
    font-size: 1.125rem;
    color: white;
}

.results-table tfoot td {
    font-weight: 600;
    color: white;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.score-number {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.25rem;
}

.averages-row td,
.averages-row th {
    background-color: var(--bg-secondary);
}

.overall-row td {
    font-size: 1.25rem;
}

footer {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
}

footer p {
    margin: 0.5rem 0;
}

footer .privacy {
    color: var(--text-muted);
    font-size: 0.75rem;
}

@media (min-width: 640px) {
    .time-periods {
        flex-direction: row;
        justify-content: space-between;
    }

    .time-period {
        flex: 1;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .legend-descriptions {
        flex-direction: column;
        gap: 0.25rem;
    }

    .legend-descriptions span {
        text-align: left !important;
    }

    .legend-num {
        display: inline;
    }

    #results-section {
        display: flex;
        flex-direction: column;
    }

    .results-header {
        flex-direction: column;
        align-items: stretch;
        order: 10;
        margin-bottom: 0;
        margin-top: 1.5rem;
    }

    .results-header h2 {
        display: none;
    }

    .scale-legend {
        order: 1;
    }

    .results-table-container {
        order: 2;
    }

    .results-table thead th {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.5rem 0.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
