/* ═══════════════════════════════════════════════════════════════════
   home.css · the homepage: a short introduction, and a game

   The game is the page's one moving thing. Everything else holds still.
   ═══════════════════════════════════════════════════════════════════ */

/* hidden means hidden, whatever display a component asks for */
.home [hidden] { display: none !important; }

main.home {
    display: flex;
    flex-direction: column;
    padding-top: 0;
    padding-bottom: clamp(40px, 8vh, 96px);
}

/* ── introduction: the first screen, centred ──────────────────────── */
.home-intro {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    /* the nav sits above this, and the game has to peek over the fold */
    min-height: calc(88vh - 72px);
    min-height: calc(88svh - 72px);
    padding: 20px 0 78px;
}
.home-portrait {
    width: clamp(120px, 13vw, 168px);
    height: clamp(120px, 13vw, 168px);
    border-radius: var(--radius);
    object-fit: cover;
    display: block;
    background: var(--bg-deep);
}
.home-intro h1 {
    font-size: clamp(2.5rem, 6.2vw, 4.4rem);
    line-height: 1.02;
    letter-spacing: -0.03em;
    margin: 20px 0 16px;
    color: var(--text);
}
.home-lede {
    font-size: clamp(1.04rem, 1.5vw, 1.2rem);
    line-height: 1.55;
    color: var(--text-soft);
    max-width: 42ch;
    margin-inline: auto;
    text-wrap: pretty;
}
.home-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 22px;
    margin-top: 26px;
    font-family: var(--f-mono);
    font-size: 0.78rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.home-stats strong {
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--text);
    margin-right: 2px;
}
.home-stats a { color: inherit; text-decoration: none; }
.home-stats a:hover strong { color: var(--accent); }

.home-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 28px;
}
.home-links a {
    font-family: var(--f-ui);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 9px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    background: var(--card);
    color: var(--text);
    text-decoration: none;
    transition: border-color 160ms cubic-bezier(.23, 1, .32, 1), transform 120ms cubic-bezier(.23, 1, .32, 1);
}
.home-links a.primary { background: var(--text); border-color: var(--text); color: var(--card); }
.home-links a:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
    .home-links a:hover { border-color: var(--accent); }
    .home-links a.primary:hover { background: var(--accent); border-color: var(--accent); }
}

/* the line that sends you to the game */
.home-cue {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    font-family: var(--f-ui);
    font-size: 0.88rem;
    color: var(--muted);
    text-decoration: none;
    transition: color 160ms var(--ease);
}
.home-cue-arrow { display: block; animation: home-bob 2s ease-in-out infinite; }
@keyframes home-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}
@media (hover: hover) and (pointer: fine) {
    .home-cue:hover { color: var(--accent); }
}

/* ── two games, two tabs ──────────────────────────────────────────── */
.play-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}
.play-tab {
    font-family: var(--f-ui);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 9px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    transition: border-color 160ms var(--ease), background-color 160ms var(--ease), color 160ms var(--ease);
}
.play-tab[aria-selected="true"] {
    background: var(--card);
    border-color: var(--border);
    color: var(--text);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--accent);
}
@media (hover: hover) and (pointer: fine) {
    .play-tab:hover { color: var(--text); border-color: var(--accent); }
}

/* ── step one to three: find a drug ───────────────────────────────── */
.fit {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(14px, 2vw, 20px);
    box-shadow: 0 28px 56px -38px rgba(24, 42, 82, 0.32);
}
.fit-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 2px 4px 10px;
}
.fit-title { font-size: 1.3rem; letter-spacing: -0.015em; color: var(--text); }
.fit-meta {
    display: flex;
    gap: 16px;
    font-family: var(--f-mono);
    font-size: 0.74rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.fit-meta strong { color: var(--text); font-weight: 600; }

.fit-steps {
    display: flex;
    gap: 18px;
    list-style: none;
    padding: 0 4px 12px;
    font-family: var(--f-mono);
    font-size: 0.72rem;
    color: var(--muted);
}
.fit-steps li { display: flex; align-items: center; gap: 6px; }
.fit-steps b {
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-weight: 600;
}
.fit-steps li[aria-current="step"] { color: var(--text); }
.fit-steps li[aria-current="step"] b { border-color: var(--accent); color: var(--accent); }
.fit-steps li.done b { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-d); }

.fit-goal {
    padding: 0 4px 12px;
    font-size: 0.94rem;
    color: var(--text-soft);
}
.fit-goal b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.fit-stage {
    position: relative;
    aspect-ratio: 3 / 2;
    width: 100%;
    max-width: calc(52vh * 1.5);
    max-width: calc(52svh * 1.5);
    margin-inline: auto;
    background: var(--bg);
    border-radius: var(--radius-s);
    overflow: hidden;
}
.fit-heat {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transition: opacity 300ms ease;
}
.fit-view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fit-static {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: clamp(14px, 4vw, 34px);
}
.fit-static p { font-size: 0.98rem; line-height: 1.55; color: var(--text-soft); max-width: 56ch; text-wrap: pretty; }
.fit-static b { color: var(--text); font-weight: 600; }

/* the map */
.fit-pt {
    fill: var(--card);
    stroke: #8d9cb8;
    stroke-width: 1.5;
    cursor: pointer;
    transition: r 200ms var(--ease);
}
.fit-pt.on { stroke: var(--text-soft); stroke-width: 1.8; }
.fit-pt.hit { stroke: var(--amber); stroke-width: 3; }
.fit-pt.sel { stroke: var(--text); stroke-width: 3; }
.fit-pt:focus { outline: none; }
.fit-pt:focus-visible { stroke: var(--text); stroke-width: 3; }
.fit-top circle {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 3 3;
}
.fit-top text {
    font-family: var(--f-mono);
    font-size: 15px;
    fill: var(--accent);
    paint-order: stroke;
    stroke: var(--bg);
    stroke-width: 3px;
    stroke-linejoin: round;
}
.fit-mark {
    fill: none;
    stroke: var(--amber);
    stroke-width: 2;
    stroke-dasharray: 4 4;
    animation: fit-pop 420ms var(--ease) backwards;
}
@keyframes fit-pop { from { opacity: 0; transform: scale(0.6); transform-origin: center; } }

/* the pocket */
.slab { stroke: rgba(110, 126, 158, 0.28); stroke-width: 0.8; }
.slab.s0 { fill: var(--bg-deep); }
.slab.s1 { fill: #d7dfee; }
.slab.s2 { fill: #c8d2e6; }
.res-dot { fill: var(--card); stroke: #8d9cb8; stroke-width: 1.2; }
.res-dot.key { stroke: var(--accent); stroke-width: 2; }
.res-label {
    font-family: var(--f-mono);
    font-size: 8px;
    fill: var(--muted);
    paint-order: stroke;
    stroke: var(--bg);
    stroke-width: 2.5px;
    stroke-linejoin: round;
}
.res-label.key { fill: var(--text); font-size: 10.5px; }
.fit-ghost line { stroke: #8894ac; stroke-width: 1.6; stroke-dasharray: 3 3; opacity: 0.7; }
.fit-ghost text { display: none; }
.fit-lig { cursor: grab; touch-action: none; }
.fit-lig.dragging { cursor: grabbing; }
.fit-lig line { stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; }
.fit-lig text { font-size: 12px; }
.fit-bench {
    fill: var(--card);
    stroke: var(--border);
    stroke-width: 1;
    transition: opacity 400ms ease;
}
.fit-bench.gone { opacity: 0; }
.fit-target {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.5;
    stroke-dasharray: 6 6;
    opacity: 0.55;
    transition: opacity 400ms ease;
}
.fit-target.gone { opacity: 0; }
.contact {
    stroke: var(--accent);
    stroke-width: 1.6;
    stroke-dasharray: 3 4;
    animation: fit-fade 320ms ease backwards;
}
@keyframes fit-fade { from { opacity: 0; } }
.fit-pose line { stroke-width: 2.4; stroke-linecap: round; }
.pose-A line { stroke: var(--accent); }
.pose-B line { stroke: var(--amber); }
.pose-A text { fill: var(--accent); }
.pose-B text { fill: var(--amber); }
.pose-tag { font-family: var(--f-mono); font-size: 11px; }
.pose-legend .swatch { stroke-width: 3; stroke-linecap: round; }
.pose-legend .swatch.pose-A { stroke: var(--accent); }
.pose-legend .swatch.pose-B { stroke: var(--amber); }
.pose-tag.pose-A { fill: var(--accent); }
.pose-tag.pose-B { fill: var(--amber); }
.fit-pose.drifted line { opacity: 0.55; }

/* what the colours mean */
.fit-key {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px auto 0;
    width: 100%;
    max-width: calc(52vh * 1.5);
    max-width: calc(52svh * 1.5);
    padding: 0 2px;
    font-family: var(--f-mono);
    font-size: 0.68rem;
    color: var(--muted);
}
.fit-ramp {
    flex: none;
    width: 96px;
    height: 8px;
    border-radius: 2px;
    background: linear-gradient(90deg, #d6ddeb, #1e56c8);
}
.fit-key-note { margin-left: auto; }

/* readout under the stage */
.fit-panel {
    display: grid;
    grid-template-columns: minmax(0, 250px) minmax(0, 1fr);
    gap: clamp(12px, 2vw, 22px);
    margin-top: 14px;
    padding: 0 4px;
}
.fit-panel.no-card { grid-template-columns: 1fr; }
.fit-card { background: var(--bg); border-radius: var(--radius-s); align-self: start; }
.fit-mol { display: block; width: 100%; height: auto; }
.fit-mol .mol line {
    stroke: var(--text);
    stroke-width: var(--stroke, 2px);
    stroke-linecap: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 280ms var(--ease);
}
.fit-mol .bond.on line { stroke-dashoffset: 0; }
.fit-mol .atom {
    font-family: var(--f-ui);
    font-weight: 600;
    opacity: 0;
    transition: opacity 220ms ease-out;
}
.fit-mol .atom.on { opacity: 1; }
.fit-mol .atom .sub { font-size: 0.7em; }
.fit-say { font-size: 1rem; line-height: 1.5; color: var(--text); max-width: 52ch; text-wrap: pretty; }
.fit-note {
    margin-top: 8px;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-soft);
    max-width: 54ch;
    text-wrap: pretty;
}
.fit-note b, .fit-say b { font-weight: 600; font-variant-numeric: tabular-nums; }
.fit-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.fit-actions:empty { margin-top: 0; }

/* the RMSD chart */
.fit-chart-wrap { margin-top: 14px; padding: 0 4px; }
.fit-chart { display: block; width: 100%; height: auto; background: var(--bg); border-radius: var(--radius-s); }
.fit-chart text { font-family: var(--f-mono); font-size: 10px; fill: var(--muted); }
.fit-chart .grid { stroke: var(--border); stroke-width: 1; }
.fit-chart .bar { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.fit-chart .series { stroke-width: 2; fill: none; stroke-linejoin: round; }
.fit-chart .s-A { stroke: var(--accent); }
.fit-chart .s-B { stroke: var(--amber); }

/* provenance, one line unless you open it */
.fit-prov {
    margin-top: 16px;
    padding: 12px 4px 0;
    border-top: 1px solid var(--border-s);
    font-family: var(--f-mono);
    font-size: 0.68rem;
    line-height: 1.62;
    color: var(--muted);
}
.fit-prov summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: baseline;
    gap: 8px;
    transition: color 160ms var(--ease);
}
.fit-prov summary::-webkit-details-marker { display: none; }
.fit-prov summary::before {
    content: "+";
    flex: none;
    width: 13px;
    text-align: center;
    color: var(--accent);
}
.fit-prov[open] summary::before { content: "\2212"; }
.fit-prov ul { list-style: none; margin-top: 10px; padding-left: 21px; }
.fit-prov li { break-inside: avoid; margin-bottom: 5px; }
@media (hover: hover) and (pointer: fine) {
    .fit-prov summary:hover { color: var(--text-soft); }
}
@media (min-width: 820px) {
    .fit-prov ul { columns: 2; column-gap: 28px; }
}
.fit-prov p { max-width: 92ch; }
.fit-prov li { max-width: 92ch; }

/* ── the game card ────────────────────────────────────────────────── */
.game {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(14px, 2vw, 20px);
    box-shadow: 0 28px 56px -38px rgba(24, 42, 82, 0.32);
}
.game-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 2px 4px 14px;
}
.game-title {
    font-size: 1.3rem;
    letter-spacing: -0.015em;
    color: var(--text);
}
.game-meta {
    display: flex;
    gap: 16px;
    font-family: var(--f-mono);
    font-size: 0.74rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.game-meta strong { color: var(--text); font-weight: 600; }

.game-stage {
    position: relative;
    aspect-ratio: 3 / 2;
    width: 100%;
    max-width: calc(52vh * 1.5);
    max-width: calc(52svh * 1.5);
    margin-inline: auto;
    background: var(--bg);
    border-radius: var(--radius-s);
    overflow: hidden;
}
.game-stage svg { display: block; width: 100%; height: 100%; }
.game-stage.shake { animation: g-shake 340ms cubic-bezier(.36, .07, .19, .97); }
@keyframes g-shake {
    0%, 100% { transform: none; }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(2px); }
}

/* the molecule */
.mol { color: var(--text); transition: opacity 380ms ease; }
.mol.out { opacity: 0; }
.mol line {
    stroke: currentColor;
    stroke-width: var(--stroke, 2.4px);
    stroke-linecap: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    fill: none;
    transition: stroke-dashoffset 300ms cubic-bezier(.23, 1, .32, 1);
}
.bond.on line { stroke-dashoffset: 0; }
.mol.win { color: var(--accent); transition: color 240ms ease, opacity 380ms ease; }

.atom {
    font-family: var(--f-ui);
    font-weight: 600;
    opacity: 0;
    transform: scale(0.8);
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity 220ms ease-out, transform 320ms cubic-bezier(.34, 1.56, .64, 1);
}
.atom.on { opacity: 1; transform: none; }
.atom .sub { font-size: 0.7em; }
.el-o { fill: #c62828; }
.el-n { fill: var(--accent); }
.el-s { fill: #8f6a2b; }
.el-x { fill: #5d5470; }

/* controls under the stage */
.game-controls { margin-top: 14px; }
.game-intro p {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-soft);
    max-width: 44ch;
    padding: 0 4px;
    text-wrap: pretty;
}
.game-intro-row, .game-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 14px;
    padding: 0 4px;
}
.game-best { font-family: var(--f-mono); font-size: 0.78rem; color: var(--muted); }
.game-best strong { color: var(--text); }

.g-btn {
    font-family: var(--f-ui);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 11px 20px;
    border-radius: var(--radius-s);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, transform 120ms cubic-bezier(.23, 1, .32, 1);
}
.g-btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; min-width: 120px; }
.g-btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
    .g-btn:hover { border-color: var(--accent); }
    .g-btn--primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
}

.game-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.g-choice {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 10px 14px;
    text-align: left;
    font-family: var(--f-ui);
    font-size: 0.98rem;
    font-weight: 500;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    cursor: pointer;
    animation: g-in 260ms cubic-bezier(.23, 1, .32, 1) backwards;
    transition: border-color 160ms cubic-bezier(.23, 1, .32, 1), background-color 200ms ease,
                color 200ms ease, opacity 200ms ease, transform 120ms cubic-bezier(.23, 1, .32, 1);
}
.g-choice:nth-child(2) { animation-delay: 40ms; }
.g-choice:nth-child(3) { animation-delay: 80ms; }
.g-choice:nth-child(4) { animation-delay: 120ms; }
@keyframes g-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.g-choice .key {
    flex: none;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    font-family: var(--f-mono);
    font-size: 0.7rem;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.g-choice:active:not(:disabled) { transform: scale(0.97); }
.g-choice:disabled { cursor: default; }
.g-choice.is-right { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-d); }
.g-choice.is-right .key { border-color: var(--accent); color: var(--accent); }
.g-choice.is-wrong { border-color: #c62828; color: #b71c1c; }
.g-choice:disabled:not(.is-right):not(.is-wrong) { opacity: 0.45; }
@media (hover: hover) and (pointer: fine) {
    .g-choice:hover:not(:disabled) { border-color: var(--accent); }
}
@media (hover: none) { .g-choice .key { display: none; } }

.game-foot {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    min-height: 80px;
    margin-top: 14px;
    padding: 0 4px;
}
.game-hint { font-family: var(--f-ui); font-size: 0.9rem; color: var(--text-soft); }
.game-hint strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.game-hint .good { color: var(--accent); }
.game-hint .plus { font-family: var(--f-mono); color: var(--accent); margin-left: 4px; }
.game-fact { margin-top: 4px; font-size: 0.95rem; line-height: 1.5; color: var(--text-soft); max-width: 48ch; text-wrap: pretty; }
.game-foot .g-btn { flex: none; }
/* nothing to say before a game starts or after it ends */
.game[data-state="idle"] .game-foot,
.game[data-state="loading"] .game-foot,
.game[data-state="done"] .game-foot { display: none; }

/* the end of a game */
.game-end {
    background: var(--bg);
    border-radius: var(--radius-s);
    padding: clamp(16px, 3vw, 24px);
}
.game-score { font-family: var(--f-mono); color: var(--muted); line-height: 1; }
.game-score strong {
    font-size: clamp(3rem, 8vw, 4.6rem);
    font-weight: 600;
    letter-spacing: -0.05em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.game-score span { font-size: 1rem; margin-left: 8px; }
.game-summary { margin-top: 12px; font-size: 1rem; color: var(--text-soft); }
.game-recap {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 20px;
}
.g-thumb {
    margin: 0;
    padding: 4px 4px 6px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    animation: g-in 320ms cubic-bezier(.23, 1, .32, 1) backwards;
}
.g-thumb:nth-child(2) { animation-delay: 40ms; } .g-thumb:nth-child(3) { animation-delay: 80ms; }
.g-thumb:nth-child(4) { animation-delay: 120ms; } .g-thumb:nth-child(5) { animation-delay: 160ms; }
.g-thumb:nth-child(6) { animation-delay: 200ms; } .g-thumb:nth-child(7) { animation-delay: 240ms; }
.g-thumb:nth-child(8) { animation-delay: 280ms; } .g-thumb:nth-child(9) { animation-delay: 320ms; }
.g-thumb:nth-child(10) { animation-delay: 360ms; }
.g-thumb svg { display: block; width: 100%; height: auto; }
.g-thumb line { stroke: var(--text); stroke-width: 1.6; stroke-linecap: round; }
.g-thumb text { font-family: var(--f-ui); font-weight: 600; }
.g-thumb figcaption {
    font-family: var(--f-ui);
    font-size: 0.66rem;
    text-align: center;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.g-thumb.hit { border-color: var(--accent); }
.g-thumb.hit line { stroke: var(--accent); }
.g-thumb.miss { opacity: 0.5; }

/* ── small screens ────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .home-intro { min-height: calc(88vh - 92px); min-height: calc(88svh - 92px); }
    .home-lede { max-width: 34ch; }
}
@media (max-width: 640px) {
    .fit-panel { grid-template-columns: 1fr; }
    .fit-card { max-width: 280px; margin-inline: auto; }
    .fit-head { flex-direction: column; gap: 6px; }
    .fit-steps { gap: 12px; }
    .res-label.key { font-size: 16px; }
    .fit-lig text, .fit-pose text, .fit-ghost text { font-size: 17px; }
    .pose-legend { transform: scale(1.7); transform-origin: 0 0; }
    .fit-top text { font-size: 26px; }
    .fit-key { font-size: 0.64rem; gap: 6px; }
    .fit-ramp { width: 64px; }
    .fit-lig line { stroke-width: 3.2; }
    .fit-pose line { stroke-width: 3.2; }
    .play-tab { flex: 1; padding: 10px 8px; text-align: center; }
}
@media (max-width: 520px) {
    .game-choices { grid-template-columns: 1fr; gap: 8px; }
    .g-choice { min-height: 48px; }
    .game-foot { flex-direction: column; }
    .game-foot .g-btn { align-self: stretch; }
    .game-recap { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
    .g-thumb figcaption { font-size: 0.58rem; }
    .game-head { flex-direction: column; gap: 6px; }
}

/* ── reduced motion: the reveal stays, because it is the game ─────── */
@media (prefers-reduced-motion: reduce) {
    .home-cue-arrow { animation: none; }
    .fit-mol .mol line { stroke-dasharray: none; stroke-dashoffset: 0; opacity: 0; transition: opacity 200ms ease; }
    .fit-mol .bond.on line { opacity: 1; }
    .fit-mark, .contact { animation: none; }
    .fit-pt { transition: none; }
    .mol line { stroke-dasharray: none; stroke-dashoffset: 0; opacity: 0; transition: opacity 240ms ease; }
    .bond.on line { opacity: 1; }
    .atom { transform: none; transition: opacity 240ms ease; }
    .g-choice, .g-thumb { animation: none; }
    .game-stage.shake { animation: none; }
}

/* ── the map camera: zoom controls, the heat as an image, molecules ── */
.fit-heat { display: none; }
.fit-heatimg { transition: opacity 300ms ease; }
.fit-stage.is-zoomed .fit-view[data-f="map"] { cursor: grab; }
.fit-stage.is-zoomed .fit-view[data-f="map"]:active { cursor: grabbing; }
.fit-view[data-f="map"] { touch-action: pan-y; }

.fit-zoom {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    z-index: 2;
}
.fit-zoom button {
    font-family: var(--f-mono);
    font-size: 0.72rem;
    line-height: 1;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    color: var(--text-soft);
    background: color-mix(in srgb, var(--card) 86%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    cursor: pointer;
}
.fit-zoom button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.fit-zoom button:disabled { opacity: 0.4; cursor: default; }

/* a compound drawn as itself, once it is big enough on screen to read */
.fit-molm { fill: none; }
.fit-molm line {
    stroke: var(--c, var(--text-soft));
    stroke-linecap: round;
}
.fit-molm text {
    font-family: var(--f-ui);
    font-weight: 600;
    fill: var(--text);
    paint-order: stroke;
    stroke: var(--bg);
}
.fit-molm text.el-o { fill: #b3402f; }
.fit-molm text.el-n { fill: var(--accent); }
.fit-molm text.el-s { fill: #8f6a2b; }
.fit-molm text.el-x { fill: #2f7d5b; }
/* a compound that is drawn as a molecule does not also need its dot */
.fit-pt.under-mol { fill-opacity: 0; stroke-opacity: 0.22; }
.fit-pt.under-mol.on { stroke-opacity: 0.8; }
.fit-pt.under-mol.sel, .fit-pt.under-mol.hit { stroke-opacity: 1; }
.fit-stage.has-mols .fit-pt { fill-opacity: 0.5; }

/* ── the pocket in three dimensions ───────────────────────────────── */
.fit-three { position: absolute; inset: 0; }
.fit-three canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
}
.fit-three canvas:active { cursor: grabbing; }
.fit-three canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.fit-3dbtn {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 2;
    font-family: var(--f-mono);
    font-size: 0.72rem;
    line-height: 1;
    padding: 7px 10px;
    color: var(--text-soft);
    background: color-mix(in srgb, var(--card) 88%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    cursor: pointer;
}
.fit-3dbtn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.fit-3dbtn:disabled { opacity: 0.45; cursor: default; }
.fit-stage.is-3d { background: var(--bg-soft); }
.fit-3dhint {
    position: absolute;
    right: 10px;
    bottom: 10px;
    margin: 0;
    font-family: var(--f-mono);
    font-size: 0.66rem;
    color: var(--muted);
    pointer-events: none;
}
@media (max-width: 560px) {
    .fit-3dhint { display: none; }
}

/* ── the target, shown beside the map while screening ─────────────── */
.fit-inset {
    position: absolute;
    left: 8px;
    top: 8px;
    z-index: 2;
    width: clamp(96px, 17%, 150px);
    padding: 6px 8px 7px;
    background: color-mix(in srgb, var(--card) 82%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    pointer-events: none;
}
.fit-inset canvas {
    display: block;
    width: 100%;
    aspect-ratio: 1;
}
.fit-inset p {
    margin: 2px 0 0;
    font-family: var(--f-mono);
    font-size: 0.6rem;
    line-height: 1.35;
    color: var(--text-soft);
}
.fit-inset p span { display: block; color: var(--accent); }
/* on a phone the map is small enough already, and the dock step shows the
   same protein in three dimensions a moment later */
@media (max-width: 560px) {
    .fit-inset { display: none; }
}

/* ── the play control, on the stage where nobody can miss it ──────── */
.fit-playbtn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 26px 14px 22px;
    font-family: var(--f-ui);
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--card);
    background: var(--accent);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 14px 30px -12px rgba(30, 86, 200, 0.55);
    transition: transform 160ms var(--ease), background-color 160ms var(--ease);
}
.fit-tri {
    width: 0;
    height: 0;
    border-left: 12px solid currentColor;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}
.fit-playbtn:hover { background: var(--accent-d); transform: translate(-50%, -50%) scale(1.04); }
.fit-playbtn:active { transform: translate(-50%, -50%) scale(0.98); }
.fit-playbtn:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
/* a quiet halo, so it reads as the thing to press */
.fit-playbtn::after {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: inherit;
    border: 1px solid var(--accent);
    opacity: 0.35;
    animation: fit-halo 2.6s ease-out infinite;
}
@keyframes fit-halo {
    0% { transform: scale(1); opacity: 0.35; }
    70%, 100% { transform: scale(1.18); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .fit-playbtn::after { animation: none; opacity: 0.3; }
    .fit-playbtn:hover { transform: translate(-50%, -50%); }
}

/* ── the wall of notes around the introduction ────────────────────────
   Wide screens scatter the notes into the space either side of him.
   Narrower ones lay them out in a row under the links, because there is
   no side space left to stick anything to. */
.wall { position: absolute; inset: 0; pointer-events: none; }
.wall-notes { list-style: none; margin: 0; padding: 0; }

.note {
    position: absolute;
    left: var(--x, 4%);
    top: var(--y, 20%);
    width: clamp(140px, 12vw, 178px);
    min-height: 104px;
    padding: 18px 14px 12px;
    background: #f7e9a0;
    border: 0;
    border-radius: 2px;
    text-align: left;
    transform: rotate(var(--r, 0deg));
    box-shadow: 0 10px 20px -12px rgba(24, 42, 82, 0.45), 0 1px 0 rgba(0, 0, 0, 0.04);
    pointer-events: auto;
}
/* the tape that holds it up */
.note-tape {
    position: absolute;
    left: 50%;
    top: -9px;
    width: 58px;
    height: 18px;
    transform: translateX(-50%) rotate(-2deg);
    background: rgba(255, 255, 255, 0.62);
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}
.note-text {
    margin: 0;
    font-family: var(--f-ui);
    font-size: 0.82rem;
    line-height: 1.45;
    color: #4a3f13;
    overflow-wrap: anywhere;
}
.note-from, .note-life {
    margin: 6px 0 0;
    font-family: var(--f-mono);
    font-size: 0.6rem;
    color: #8a7526;
}
.note-life { opacity: 0.72; }
.note.is-new { animation: note-stick 420ms var(--ease-spring, cubic-bezier(.34,1.56,.64,1)) both; }
@keyframes note-stick {
    from { transform: rotate(var(--r, 0deg)) scale(0.82) translateY(-10px); opacity: 0; }
    to   { transform: rotate(var(--r, 0deg)) scale(1) translateY(0); opacity: 1; }
}

/* the invitation is a note nobody has written on yet */
.note-add {
    background: transparent;
    border: 1.5px dashed #c9b978;
    box-shadow: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    gap: 4px;
    color: #8a7526;
    transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}
.note-add .note-text { color: inherit; text-align: center; }
.note-add .note-plus { font-size: 1.3rem; line-height: 1; }
.note-add .note-tape { opacity: 0.5; }
.note-add:hover { background: rgba(247, 233, 160, 0.5); border-color: #a8912f; }
.wall-said {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    margin: 0;
    text-align: center;
    font-family: var(--f-mono);
    font-size: 0.66rem;
    color: var(--muted);
}

/* ── writing one ──────────────────────────────────────────────────── */
.wall-dialog {
    width: min(340px, calc(100vw - 32px));
    /* the site reset zeroes every margin, which would pin a modal dialog to
       the top left, so it asks for its centring back */
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: #f7e9a0;
    box-shadow: 0 40px 80px -30px rgba(24, 42, 82, 0.5);
    color: #4a3f13;
}
.wall-dialog::backdrop { background: rgba(18, 26, 44, 0.34); }
.wall-form { position: relative; padding: 24px 20px 18px; display: grid; gap: 6px; }
.wall-lab {
    font-family: var(--f-mono);
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #8a7526;
}
.wall-form textarea, .wall-form input[type="text"] {
    width: 100%;
    font-family: var(--f-ui);
    font-size: 0.9rem;
    color: #3b3210;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(138, 117, 38, 0.35);
    border-radius: 2px;
    padding: 8px 10px;
    resize: none;
}
.wall-form textarea:focus, .wall-form input:focus { outline: 2px solid #8a7526; outline-offset: 1px; }
.wall-count { margin: 0; font-family: var(--f-mono); font-size: 0.6rem; color: #8a7526; text-align: right; }
.wall-send {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 4px;
    font-family: var(--f-ui);
    font-size: 0.78rem;
}
.wall-buttons { display: flex; gap: 8px; margin-top: 8px; }
.wall-stick, .wall-cancel {
    font-family: var(--f-ui);
    font-size: 0.86rem;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: var(--radius-s);
    cursor: pointer;
}
.wall-stick { background: #4a3f13; color: #f7e9a0; border: 0; }
.wall-stick:hover { background: #6b5a1c; }
.wall-cancel { background: transparent; border: 1px solid rgba(74, 63, 19, 0.35); color: #4a3f13; }
.wall-fine { margin: 8px 0 0; font-family: var(--f-mono); font-size: 0.58rem; line-height: 1.5; color: #8a7526; }

/* under 1180px there is no room beside him, so the notes queue up below */
@media (max-width: 1180px) {
    .wall {
        position: static;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        gap: 14px;
        margin-top: 30px;
        pointer-events: auto;
    }
    .wall-notes { display: contents; }
    .note { position: static; transform: rotate(var(--r, 0deg)); width: 150px; }
    .wall-said { position: static; flex-basis: 100%; margin-top: 6px; }
}
@media (max-width: 560px) {
    .note { width: 132px; min-height: 92px; padding: 16px 11px 10px; }
}
