:root {
    --ink: #173f3a;
    --ink-dark: #102d2a;
    --paper: #f5f0e6;
    --paper-light: #fffdf8;
    --accent: #e7653f;
    --accent-dark: #c84d2b;
    --mint: #c8ded7;
    --line: rgba(23, 63, 58, 0.18);
    --muted: #60736f;
    --danger: #b33b2e;
    --success: #23715f;
    --shadow: 0 24px 65px rgba(23, 63, 58, 0.12);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 88% 8%, rgba(231, 101, 63, 0.16), transparent 24rem),
        linear-gradient(135deg, transparent 0 49.7%, rgba(23, 63, 58, 0.045) 49.8% 50.2%, transparent 50.3%) 0 0 / 38px 38px,
        var(--paper);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.site-header {
    width: min(1200px, calc(100% - 40px));
    height: 88px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-logo {
    display: block;
    width: auto;
    height: 54px;
    object-fit: contain;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: var(--paper-light);
    background: var(--ink);
    border-radius: 50%;
    font-family: Georgia, serif;
    font-size: 1.25rem;
}

.quiet-link, .quiet-button {
    border: 0;
    color: var(--ink);
    background: transparent;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.quiet-link:hover, .quiet-button:hover { color: var(--accent-dark); }

.page-shell {
    width: min(1200px, calc(100% - 40px));
    min-height: calc(100vh - 88px);
    margin: 0 auto;
    display: grid;
    align-items: center;
    padding: 56px 0 80px;
}

.welcome-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    align-items: center;
    gap: clamp(48px, 8vw, 120px);
}

.eyebrow {
    margin: 0 0 14px;
    color: var(--accent-dark);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h1, h2 { margin: 0; color: var(--ink-dark); letter-spacing: -0.055em; line-height: 0.98; }
h1 { max-width: 720px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3.5rem, 8vw, 7.4rem); font-weight: 500; }
h2 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.2rem, 4vw, 3.4rem); font-weight: 500; }

.lede {
    max-width: 620px;
    margin: 28px 0 36px;
    color: var(--muted);
    font-size: clamp(1rem, 1.8vw, 1.22rem);
    line-height: 1.7;
}

.practice-facts { display: flex; gap: clamp(24px, 5vw, 64px); }
.practice-facts div { display: grid; gap: 4px; }
.practice-facts strong { color: var(--accent); font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.practice-facts span { color: var(--muted); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }

.entry-card, .login-card {
    position: relative;
    overflow: hidden;
    padding: clamp(32px, 5vw, 60px);
    background: var(--paper-light);
    border: 1px solid rgba(23, 63, 58, 0.1);
    border-radius: 4px 44px 4px 4px;
    box-shadow: var(--shadow);
}

.entry-card::after, .login-card::after {
    content: "";
    position: absolute;
    right: -68px;
    bottom: -68px;
    width: 180px;
    height: 180px;
    border: 30px solid var(--mint);
    border-radius: 50%;
    pointer-events: none;
}

.step-mark {
    position: absolute;
    top: 26px;
    right: 30px;
    color: var(--mint);
    font-family: Georgia, serif;
    font-size: 3.5rem;
    line-height: 1;
}

.entry-card > p:not(.eyebrow):not(.form-error), .login-card > p:not(.eyebrow) { margin: 20px 0 32px; color: var(--muted); line-height: 1.6; }
label { display: block; margin-bottom: 9px; color: var(--ink); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }

input {
    width: 100%;
    min-height: 52px;
    padding: 12px 15px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--ink-dark);
    background: #fff;
    outline: none;
}

input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(231, 101, 63, 0.14); }

.primary-button {
    position: relative;
    z-index: 1;
    min-height: 52px;
    padding: 0 22px;
    border: 0;
    border-radius: 4px;
    color: white;
    background: var(--accent);
    font-weight: 850;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease;
}

.entry-card .primary-button, .login-form .primary-button { width: 100%; margin-top: 16px; display: flex; align-items: center; justify-content: space-between; }
.primary-button:hover:not(:disabled) { background: var(--accent-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: 0.55; cursor: not-allowed; }
.form-error { min-height: 20px; margin: 8px 0 0; color: var(--danger); font-size: 0.85rem; }

.practice-screen { width: min(920px, 100%); margin: 0 auto; }
.practice-topline { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 24px; }
.practice-topline h1 { font-size: clamp(2.5rem, 6vw, 4.5rem); }
.question-meta { display: flex; align-items: center; gap: 16px; color: var(--muted); font-weight: 800; }
.type-chip { padding: 8px 11px; color: var(--ink); background: var(--mint); border-radius: 100px; font-size: 0.82rem; }
.progress-track { height: 5px; margin-bottom: 22px; overflow: hidden; background: rgba(23, 63, 58, 0.12); border-radius: 20px; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 300ms ease; }

.stage-card {
    min-height: min(66vh, 620px);
    padding: 32px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    place-items: center;
    background: var(--ink);
    border-radius: 4px 54px 4px 4px;
    box-shadow: var(--shadow);
}

.stage-kicker { align-self: start; margin: 0; color: var(--mint); font-size: 0.76rem; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; }
.flash-number { color: var(--paper-light); font-family: Georgia, serif; font-size: clamp(6.5rem, 19vw, 13rem); letter-spacing: -0.07em; line-height: 1; opacity: 0.38; transform: scale(0.98); transition: opacity 100ms ease, transform 100ms ease; }
.flash-number.is-visible { opacity: 1; transform: scale(1); }
.answer-form { align-self: end; width: min(520px, 100%); }
.answer-form label { color: var(--paper-light); text-align: center; }
.answer-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.answer-row input { min-height: 58px; font-size: 1.15rem; text-align: center; }
.answer-row .primary-button { min-height: 58px; }
.timer-line { margin-top: 12px; display: flex; justify-content: space-between; color: var(--mint); font-size: 0.85rem; }
.answer-form .form-error { color: #ffb5a1; text-align: center; }

.result-screen { width: min(740px, 100%); margin: auto; padding: 68px; text-align: center; background: var(--paper-light); border-radius: 4px 54px 4px 4px; box-shadow: var(--shadow); }
.result-screen h1 { margin: 18px auto 24px; font-size: clamp(3rem, 7vw, 5.4rem); }
.result-symbol { width: 82px; height: 82px; margin: 0 auto 30px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--success); font-size: 3rem; }
.result-symbol.failed { background: var(--danger); }
.result-message { max-width: 540px; margin: 0 auto 32px; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }

.admin-shell { width: min(1200px, calc(100% - 40px)); margin: 0 auto; padding: 64px 0 90px; }
.login-card { width: min(500px, 100%); margin: 7vh auto 0; }
.login-card h1 { font-size: clamp(3rem, 7vw, 4.8rem); }
.login-form { display: grid; }
.login-form label:not(:first-of-type) { margin-top: 18px; }
.notice { margin: 22px 0; padding: 14px; color: var(--danger); background: rgba(179, 59, 46, 0.08); border-left: 3px solid var(--danger); line-height: 1.5; }
.notice code { font-size: 0.8em; }

.admin-heading { display: flex; align-items: end; justify-content: space-between; gap: 40px; }
.admin-heading h1 { font-size: clamp(3rem, 6vw, 5.6rem); }
.admin-heading > div > p:last-child { color: var(--muted); }
.admin-actions { width: min(300px, 100%); display: grid; gap: 10px; }
.search-field { width: min(300px, 100%); }
.export-button {
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 4px;
    color: var(--paper-light);
    background: var(--ink);
    font-weight: 800;
    cursor: pointer;
}
.export-button:hover:not(:disabled) { background: var(--ink-dark); }
.export-button:disabled { opacity: 0.45; cursor: not-allowed; }
.export-status { min-height: 1em; color: var(--muted); font-size: 0.78rem; }
.summary-grid { margin: 48px 0 24px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.summary-grid article { padding: 22px; display: grid; gap: 10px; background: var(--ink); color: var(--paper-light); border-radius: 4px 20px 4px 4px; }
.summary-grid article span { color: var(--mint); font-size: 0.73rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.summary-grid article strong { font-family: Georgia, serif; font-size: 2.5rem; font-weight: 500; }
.summary-grid article small { color: var(--mint); font-family: inherit; font-size: 0.85rem; }

.results-panel { overflow: hidden; background: var(--paper-light); border: 1px solid var(--line); border-radius: 4px 28px 4px 4px; box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 15px 18px; color: var(--muted); background: rgba(200, 222, 215, 0.35); font-size: 0.71rem; letter-spacing: 0.08em; text-transform: uppercase; }
td { padding: 18px; border-top: 1px solid var(--line); white-space: nowrap; font-size: 0.9rem; }
td:first-child { min-width: 180px; }
.attempt-id { display: block; margin-top: 4px; color: var(--muted); font-family: ui-monospace, monospace; font-size: 0.7rem; }
.status-badge { display: inline-block; padding: 6px 9px; border-radius: 100px; font-size: 0.72rem; font-weight: 850; }
.status-badge.complete { color: var(--success); background: rgba(35, 113, 95, 0.12); }
.status-badge.failed { color: var(--danger); background: rgba(179, 59, 46, 0.1); }
.empty-state { min-height: 260px; display: grid; place-content: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }

@media (max-width: 820px) {
    .welcome-grid { grid-template-columns: 1fr; }
    .intro-copy { text-align: center; }
    .lede { margin-left: auto; margin-right: auto; }
    .practice-facts { justify-content: center; }
    .admin-heading { align-items: stretch; flex-direction: column; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
    .site-header, .page-shell, .admin-shell { width: min(100% - 24px, 1200px); }
    .site-header { height: 72px; }
    .brand-logo { height: 44px; }
    .page-shell { min-height: calc(100vh - 72px); padding-top: 34px; }
    .welcome-grid { gap: 40px; }
    .practice-facts { gap: 20px; }
    .entry-card, .login-card, .result-screen { padding: 28px 22px; }
    .practice-topline { align-items: start; }
    .question-meta { align-items: end; flex-direction: column; gap: 8px; }
    .stage-card { min-height: 64vh; padding: 24px 18px; }
    .answer-row { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
}

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