/* Who's That Red? - matchday-programme heritage (cream, red masthead, serif display type) on a clean,
   single-column card layout. Mobile first; the column stays narrow on desktop on purpose. */

:root {
    --red: #c8102e;
    --red-dark: #9b0c23;
    --ink: #1f1b16;
    --muted: #5f574c;       /* 6.3:1 on --page */
    --line: #ddd4c4;
    --page: #f6f1e6;
    --card: #fffdf8;
    --chip: #efe9dc;
    --green: #1f6b45;       /* 6.6:1 with white text */
    --orange: #d9822b;
    --miss: #9b866a;        /* neutral tan for a wrong guess (not brand red); 3.4:1 on --card */
    --bar: #e2d9c8;         /* neutral distribution bar; --ink on it is 12:1 */
    --empty: #e4ddd0;
    --radius: 14px;
    --serif: "Playfair Display", Georgia, "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--page);
}

* { box-sizing: border-box; }

body { margin: 0; }

.page {
    max-width: 460px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 0.75rem 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

[hidden] { display: none !important; }

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

a { color: var(--red-dark); }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.masthead :focus-visible { outline-color: #fff; }

/* ---- Masthead ---------------------------------------------------------------------------- */

.masthead {
    background: var(--red);
    color: #fff;
    border-radius: var(--radius);
    padding: 0.7rem 1rem 0.8rem;
}

.masthead-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
}

.masthead-small {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.masthead-tools { display: inline-flex; gap: 0.15rem; margin: -0.6rem -0.65rem -0.6rem 0; }

.icon-button {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.icon-button:hover { background: rgba(255, 255, 255, 0.14); }

.icon-button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-button svg .dot { fill: currentColor; }

.masthead-title {
    font-family: var(--serif);
    font-size: clamp(1.8rem, 7.5vw, 2.2rem);
    font-weight: 700;
    line-height: 1.1;
    margin: 0.2rem 0 0.3rem;
}

.masthead-date {
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ---- Status and progress ----------------------------------------------------------------- */

.status { margin: 0; color: var(--muted); }
.status:empty { display: none; }

.eyebrow {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.progress-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
}

.progress-text {
    margin: 0.15rem 0 0;
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 700;
}

.streak {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0 0 0.15rem;
    font-weight: 700;
}

.streak-icon { width: 18px; height: 18px; fill: none; stroke: var(--red); stroke-width: 2; stroke-linejoin: round; }

.progress {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    list-style: none;
    margin: 0.6rem 0 1rem;
    padding: 0;
}

.progress li { height: 7px; border-radius: 999px; background: var(--line); }
.progress li.miss { background: var(--miss); }
.progress li.close { background: var(--orange); }
.progress li.correct { background: var(--green); }

/* ---- Cards and tiles --------------------------------------------------------------------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
}

.card-heading, .section-heading {
    font-family: var(--serif);
    font-weight: 700;
    margin: 0 0 0.75rem;
}

.card-heading { font-size: 1.3rem; }
.card-heading-small, .section-heading { font-size: 1.15rem; }

.tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin: 0;
}

.tile {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.6rem 0.7rem;
    min-height: 66px;
    background: var(--card);
    min-width: 0;
}

.tile dt {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
}

.tile dd {
    margin: 0.25rem 0 0;
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    overflow-wrap: anywhere;
}

.tile-locked { border-style: dashed; background: transparent; }
.tile-locked dd { font-size: 0.88rem; font-weight: 500; color: var(--muted); }

.lock { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; flex: none; }

.flag { width: 22px; height: auto; border-radius: 2px; box-shadow: 0 0 0 1px var(--line); }

/* ---- Guess entry ------------------------------------------------------------------------- */

.guess-entry { margin-top: 1.25rem; }

.combo { position: relative; }

#guess-input {
    width: 100%;
    min-height: 48px;
    padding: 0.7rem 1rem;
    font: inherit;
    font-size: 1rem;
    color: var(--ink);
    background: var(--card);
    border: 1px solid #b9ad99;
    border-radius: 999px;
}

#guess-input::placeholder { color: #776d5c; }

.suggestions {
    position: absolute;
    z-index: 5;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    list-style: none;
    margin: 0;
    padding: 0.3rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(31, 27, 22, 0.14);
}

.suggestion {
    min-height: 44px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
}

.suggestion-active { background: var(--chip); }
.suggestion-alias { font-size: 0.85rem; color: var(--muted); }

.primary-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 48px;
    margin-top: 0.6rem;
    padding: 0.6rem 1rem;
    font: inherit;
    font-weight: 700;
    border: 0;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    cursor: pointer;
}

.primary-button:hover:not(:disabled) { background: var(--red-dark); }
.primary-button:disabled { background: var(--empty); color: #6a6151; cursor: not-allowed; }

.button-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

.guess-status { margin: 0.5rem 0 0; font-size: 0.9rem; color: var(--muted); text-align: center; }
.guess-status:empty { display: none; }

/* ---- Guess history ----------------------------------------------------------------------- */

.history { margin-top: 1.25rem; }

.history-head { display: flex; justify-content: space-between; align-items: baseline; }
.history-count { font-size: 0.85rem; color: var(--muted); }

.guess-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }

.guess {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
}

.guess-correct { border: 1.5px solid var(--green); }

.guess-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.guess-name { margin: 0; font-family: var(--serif); font-size: 1.1rem; font-weight: 700; }
.guess-meta { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.guess-figures { margin: 0.15rem 0 0; font-size: 0.8rem; color: var(--muted); }
.guess-check { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.55rem; padding: 0; list-style: none; }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--chip);
    border: 1px solid var(--line);
    color: var(--ink);
}

.chip-match { background: var(--green); border-color: var(--green); color: #fff; }

/* ---- Reveal ------------------------------------------------------------------------------ */

.reveal { margin-top: 0.25rem; border-top: 4px solid var(--red); outline: none; }

.reveal-verdict {
    margin: 0 0 0.85rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--red-dark);
}

.reveal-verdict-won { color: var(--green); }

.reveal-head { display: flex; align-items: center; gap: 1rem; }

.portrait {
    flex: none;
    width: 96px;
    height: 124px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--chip);
}

.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }

.portrait.monogram {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--red);
    color: #fff;
    font-family: var(--serif);
    font-size: 1.9rem;
    font-weight: 700;
}

.reveal-name { margin: 0 0 0.25rem; font-family: var(--serif); font-size: 1.6rem; line-height: 1.15; }

.reveal-line {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.reveal-line:empty { display: none; }

.big-figures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 1rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    text-align: center;
}

.big-figure { display: flex; flex-direction: column-reverse; }
.big-figure dd { margin: 0; font-family: var(--serif); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.big-figure dt { font-size: 0.85rem; color: var(--muted); }

.profile-link-row { margin: 0.4rem 0 0; text-align: center; }

.profile-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 44px;
    padding: 0 0.5rem;
    font-weight: 700;
    text-decoration: none;
}

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

.result {
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.slots { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; gap: 6px; }

.slot {
    display: inline-block;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--empty);
    vertical-align: middle;
}

.slot-correct { background: var(--green); }
.slot-close { background: var(--orange); }
.slot-miss { background: var(--miss); }
.slot-unused { background: var(--empty); box-shadow: inset 0 0 0 1px var(--line); }

.share-feedback {
    margin: 0.6rem auto 0;
    width: fit-content;
    max-width: 100%;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 0.85rem;
    white-space: pre-line;
}

.share-feedback:empty { display: none; }

/* ---- Your record ------------------------------------------------------------------------- */

.record .stats-grid { margin-top: 0; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin: 1rem 0 0;
    text-align: center;
}

.stat { display: flex; flex-direction: column-reverse; }
.stat-value { margin: 0; font-family: var(--serif); font-size: 1.6rem; font-weight: 700; }
.stat-label { font-size: 0.78rem; color: var(--muted); }

.countdown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 1rem 0 0;
    padding-top: 0.9rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
}

.clock { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }

/* ---- Dialogs ----------------------------------------------------------------------------- */

.dialog {
    width: min(420px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--ink);
    padding: 1.25rem;
}

.dialog::backdrop { background: rgba(31, 27, 22, 0.55); }
.dialog h2 { font-family: var(--serif); margin: 0 0 0.5rem; }
.dialog h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }
.dialog p { margin: 0 0 0.75rem; line-height: 1.45; }

.help-list { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.7rem; line-height: 1.45; }

.legend { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.35rem; font-size: 0.92rem; }
.legend .slot { width: 18px; height: 18px; flex: none; }

.distribution { list-style: none; margin: 0 0 0.5rem; padding: 0; display: grid; gap: 0.3rem; }
.distribution-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.distribution-label { width: 1rem; flex: none; text-align: right; font-weight: 700; }
.distribution-track { flex: 1; }
.distribution-bar {
    display: block;
    min-width: 1.75rem;
    box-sizing: border-box;
    background: var(--bar);
    color: var(--ink);
    text-align: right;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-weight: 700;
}
.distribution-bar-latest { background: var(--green); color: #fff; }
.stats-note { font-size: 0.8rem; color: var(--muted); }

/* ---- Footer ------------------------------------------------------------------------------ */

.footer {
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--muted);
}

.footer a { font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.footer a:hover { text-decoration: underline; }

/* The tagline never breaks mid-phrase: on a narrow phone the date drops to its own line instead. */
.masthead-row:last-child { flex-wrap: wrap; row-gap: 0.1rem; }
.masthead-row:last-child { column-gap: 0.5rem; }
.masthead-tagline { white-space: nowrap; font-size: 0.8rem; }
.masthead-date { font-size: 0.8rem; letter-spacing: 0.04em; }
.record { margin-top: 0.75rem; }

/* ---- "Did you know?" ------------------------------------------------------------------------ */

.fact {
    margin: 1rem 0 0;
    padding: 0.8rem 0.9rem 0.3rem;
    border-radius: 10px;
    background: var(--page);
    border-left: 4px solid var(--red);
}

.fact-heading { margin: 0 0 0.3rem; font-family: var(--serif); font-size: 1rem; }
.fact-text { margin: 0; font-size: 0.92rem; line-height: 1.45; }
.fact .profile-link-row { text-align: left; margin-top: 0.15rem; }
.fact .profile-link { padding: 0; }

/* Help: the feedback legend */
.chip-legend { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; gap: 0.35rem; font-size: 0.92rem; }
.chip-legend .chip { display: inline-flex; min-width: 2.6rem; justify-content: center; margin-right: 0.4rem; }
