:root {
    --navy: #183153;
    --navy-light: #2b5278;
    --gold: #d4a017;
    --gold-light: #fff8e6;
    --ink: #273444;
    --muted: #657286;
    --line: #d7dee7;
    --surface: #ffffff;
    --background: #f4f7fa;
    --shadow: 0 14px 38px rgba(24, 49, 83, 0.11);
}

* {
    box-sizing: border-box;
}

body {
    max-width: 1200px;
    min-height: 100vh;
    margin: auto;
    padding: 24px;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.6;
    color: var(--ink);
    background: var(--background);
}

button,
input,
select {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(212, 160, 23, 0.55);
    outline-offset: 3px;
}

.site-header {
    margin-bottom: 26px;
}

.home-link {
    display: inline-block;
    margin-bottom: 26px;
    color: var(--navy);
    font-weight: 700;
    text-decoration: none;
}

.home-link:hover {
    text-decoration: underline;
}

.heading-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 3px solid var(--gold);
    padding-bottom: 17px;
}

.eyebrow,
.card-label {
    margin: 0 0 4px;
    color: var(--navy-light);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: var(--navy);
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1.15;
}

.intro {
    margin: 8px 0 0;
    color: var(--muted);
}

.result-count {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 7px 13px;
    color: var(--navy);
    background: #e7edf5;
    font-size: 0.9rem;
    font-weight: 700;
}

.controls,
.flashcard,
.message-panel {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.controls {
    margin-bottom: 28px;
    padding: 22px;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--navy);
    font-size: 0.88rem;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 46px;
    border: 1px solid #b8c2cf;
    border-radius: 7px;
    padding: 9px 12px;
    color: var(--ink);
    background: #fff;
}

input:focus,
select:focus {
    border-color: var(--navy-light);
}

.search-field {
    margin-bottom: 17px;
}

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

.clear-button {
    margin-top: 16px;
    border: 0;
    padding: 4px 0;
    color: var(--navy-light);
    background: transparent;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: underline;
}

.flashcard {
    min-height: 390px;
    padding: clamp(24px, 5vw, 48px);
    border-top: 6px solid var(--navy);
}

.card-topline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 42px;
}

.counter {
    flex: 0 0 auto;
    color: var(--muted);
    font-weight: 700;
}

.metadata {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.badge {
    border: 1px solid #cad5e2;
    border-radius: 999px;
    padding: 4px 10px;
    color: var(--navy);
    background: #eef4fa;
    font-size: 0.78rem;
    font-weight: 700;
}

.badge-difficulty {
    border-color: #ecd68d;
    background: var(--gold-light);
}

#question {
    max-width: 900px;
    margin: 8px 0 30px;
    color: var(--navy);
    font-size: clamp(1.45rem, 3vw, 2.15rem);
    line-height: 1.35;
}

.answer {
    margin: 0 0 26px;
    border-left: 5px solid var(--gold);
    padding: 16px 20px;
    background: var(--gold-light);
}

.answer p:last-child {
    margin: 5px 0 0;
    font-size: 1.1rem;
}

button {
    min-height: 44px;
    border: 1px solid var(--navy);
    border-radius: 7px;
    padding: 9px 18px;
    color: var(--navy);
    background: #fff;
    font-weight: 700;
}

button:hover:not(:disabled) {
    color: #fff;
    background: var(--navy);
}

.reveal-button {
    color: #fff;
    background: var(--navy);
}

.reveal-button:hover {
    background: var(--navy-light) !important;
}

.card-navigation {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 18px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.message-panel {
    padding: 32px;
    text-align: center;
}

.message-panel h2 {
    margin: 0 0 8px;
    color: var(--navy);
}

.message-panel p {
    margin: 0;
    color: var(--muted);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

[hidden] {
    display: none !important;
}

@media (max-width: 800px) {
    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .card-topline {
        display: block;
        margin-bottom: 32px;
    }

    .metadata {
        justify-content: flex-start;
        margin-top: 12px;
    }
}

@media (max-width: 520px) {
    body {
        padding: 16px;
    }

    .heading-row {
        display: block;
    }

    .result-count {
        display: inline-block;
        margin-top: 16px;
    }

    .controls {
        padding: 17px;
    }

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

    .flashcard {
        min-height: 0;
        padding: 22px 19px;
    }

    .card-navigation {
        grid-template-columns: 1fr 1fr;
    }

    #random-card {
        grid-column: 1 / -1;
        grid-row: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
    }
}
