/*
 * Fluency Dash. Plain CSS on purpose: the servers serve a prebuilt Tailwind
 * file, and a class it has never seen does nothing. Nothing here needs a build.
 *
 * The scene art stays light in both themes. Only the top bar follows the
 * portal's dark mode.
 */

:root {
    --fd-sky: #f0f8fc;
    --fd-scene-sky: #d7edfa;
    --fd-ink: #1b2b3a;
    --fd-ink-2: #3c5061;
    --fd-muted: #56687a;
    --fd-line: #d3e2ec;
    --fd-card: #ffffff;
    --fd-primary: #0e7c74;
    --fd-primary-dark: #0a5f59;
    --fd-focus: #1d4ed8;
    --fd-font: 'Baloo 2', ui-rounded, 'Segoe UI', system-ui, sans-serif;
    --fd-hand: 'Patrick Hand', 'Baloo 2', 'Comic Sans MS', cursive;
    --fd-bar-h: 48px;
    --fd-screen-h: calc(100vh - var(--fd-bar-h));

    /* one accent per operation, taken from the tiles */
    --op-accent: #0e7c74;
    --op-ink: #0b6259;
    --op-soft: #ddf4ef;
    --op-border: #9fd8cc;
}

@supports (height: 100dvh) {
    :root { --fd-screen-h: calc(100dvh - var(--fd-bar-h)); }
}

[data-op="subtraction"] { --op-accent: #d9730d; --op-ink: #9a4a05; --op-soft: #fff2d8; --op-border: #f2cd88; }
[data-op="multiplication"] { --op-accent: #2563eb; --op-ink: #1c4fc0; --op-soft: #e2ecfe; --op-border: #a9c5f6; }
[data-op="division"] { --op-accent: #7c4ddf; --op-ink: #5d34b8; --op-soft: #efe8fe; --op-border: #cbb8f6; }

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

[x-cloak] { display: none !important; }

.fd-body {
    margin: 0;
    background: var(--fd-sky);
    color: var(--fd-ink);
    font-family: var(--fd-font);
    font-size: 18px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

[tabindex="-1"]:focus { outline: none; }

button { font: inherit; color: inherit; }

.fd-app { min-height: 100vh; display: flex; flex-direction: column; }
.fd-main { flex: 1; display: flex; flex-direction: column; }

.fd-screen {
    position: relative;
    min-height: var(--fd-screen-h);
    animation: fd-in 0.22s ease-out both;
}

@keyframes fd-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Buttons ------------------------------------------------------------------ */

.fd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 48px;
    padding: 8px 20px;
    border-radius: 14px;
    border: 2px solid #c3d5e0;
    background: #fff;
    box-shadow: 0 3px 0 #c3d5e0;
    color: var(--fd-ink);
    font: 700 18px/1.1 var(--fd-font);
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, background-color 0.12s;
    -webkit-tap-highlight-color: transparent;
}

.fd-btn:hover { background: #f3f8fb; }
.fd-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c3d5e0; }
.fd-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.fd-btn--primary {
    background: var(--fd-primary);
    border-color: var(--fd-primary-dark);
    box-shadow: 0 3px 0 var(--fd-primary-dark);
    color: #fff;
}

.fd-btn--primary:hover { background: #0b6d66; }
.fd-btn--primary:active { box-shadow: 0 1px 0 var(--fd-primary-dark); }

.fd-btn:focus-visible,
.fd-key:focus-visible,
.fd-level-btn:focus-visible,
.fd-offer__link:focus-visible,
.fd-bar__back:focus-visible {
    outline: 4px solid var(--fd-focus);
    outline-offset: 3px;
}

.fd-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.fd-actions--start { justify-content: flex-start; margin-top: 18px; }

.fd-alert {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 14px;
    border: 2px solid #f3c1ba;
    background: #fdece9;
    color: #8a1c12;
    font-weight: 600;
}

.fd-alert p { margin: 0; }

/* Top bar ------------------------------------------------------------------ */

.fd-bar {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--fd-bar-h);
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid #d9e6ee;
    color: var(--fd-ink);
}

.fd-app[data-screen="operation"] .fd-bar { background: var(--fd-sky); border-bottom-color: transparent; }

.fd-bar__logo { display: block; height: 26px; width: auto; }
.fd-bar__logo--dark { display: none; }

.fd-bar__title {
    padding-left: 12px;
    border-left: 2px solid #d9e6ee;
    color: var(--fd-ink-2);
    font-weight: 700;
    font-size: 17px;
    white-space: nowrap;
}

.fd-bar__gap { flex: 1; }
.fd-bar__saving { color: var(--fd-muted); font-size: 15px; font-weight: 600; }

.fd-bar__player {
    max-width: 10em;
    overflow: hidden;
    color: var(--fd-ink-2);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fd-bar__back {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-height: 44px;
    padding: 4px 14px 4px 8px;
    border-radius: 12px;
    border: 2px solid #c3d5e0;
    background: #fff;
    color: var(--fd-ink);
    font-weight: 700;
    font-size: 17px;
    text-decoration: none;
}

.fd-bar__back:hover { background: #f3f8fb; }

html.dark .fd-bar,
html.dark .fd-app[data-screen="operation"] .fd-bar {
    background: #0f172a;
    border-bottom-color: #1e293b;
    color: #e2e8f0;
}

html.dark .fd-bar__logo--light { display: none; }
html.dark .fd-bar__logo--dark { display: block; }
html.dark .fd-bar__title { color: #cbd5e1; border-left-color: #334155; }
html.dark .fd-bar__player,
html.dark .fd-bar__saving { color: #cbd5e1; }
html.dark .fd-bar__back { background: #1e293b; border-color: #475569; color: #e2e8f0; }
html.dark .fd-bar__back:hover { background: #273449; }
html.dark .fd-bar__back:focus-visible { outline-color: #93c5fd; }

@media (max-width: 640px) {
    .fd-bar { gap: 8px; padding: 0 12px; }
    .fd-bar__title { display: none; }
    .fd-bar__logo { height: 22px; }
}

@media (max-width: 380px) {
    .fd-bar__player { display: none; }
}

/* Screen 1: choose an operation. Phones and narrow windows first. ----------- */

.fd-op {
    overflow: hidden;
    padding: 12px 16px 20px;
    background: linear-gradient(180deg, var(--fd-sky) 0%, #eef8fc 50%, #e4f2d3 100%);
}

.fd-op__backdrop,
.fd-scene__bg,
.fd-bubble,
.fd-sign-text,
.fd-rock-text { display: none; }

.fd-op__cloud {
    position: absolute;
    z-index: 0;
    height: auto;
    opacity: 0.9;
    pointer-events: none;
}

.fd-op__cloud--a { top: 6px; left: -34px; width: 118px; }
.fd-op__cloud--b { top: 64px; right: -44px; width: 132px; }

.fd-scene { position: relative; z-index: 1; max-width: 900px; margin: 0 auto; }

.fd-hero { text-align: center; }
.fd-hero__banner { display: block; width: min(100%, 440px); height: auto; margin: 0 auto; }

.fd-hero__lead {
    max-width: 30em;
    margin: 6px auto 16px;
    font: 400 19px/1.3 var(--fd-hand);
    color: var(--fd-ink);
}

.fd-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 12px;
    max-width: 460px;
    margin: 0 auto;
}

.fd-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.fd-tile__face {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 285 / 309;
    border-radius: 14%;
    transition: transform 0.16s ease-out, filter 0.16s ease-out;
}

.fd-tile__face img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.fd-tile__word {
    position: absolute;
    left: 6%;
    right: 6%;
    bottom: 14%;
    font: 400 clamp(19px, 5vw, 26px)/1 var(--fd-hand);
    color: var(--fd-ink);
    -webkit-text-stroke: 0.03em currentColor;
    text-align: center;
    white-space: nowrap;
}

.fd-tile:hover .fd-tile__face { transform: translateY(-4px); filter: drop-shadow(0 8px 8px rgba(24, 60, 84, 0.18)); }
.fd-tile:active .fd-tile__face { transform: translateY(1px) scale(0.98); filter: none; }
.fd-tile:focus-visible { outline: none; }
.fd-tile:focus-visible .fd-tile__face { outline: 4px solid var(--fd-focus); outline-offset: 3px; }

.fd-tile__last {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    margin-top: 6px;
    padding: 3px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--fd-ink-2);
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
    text-align: center;
}

.fd-op__friend {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}

.fd-op__friend img { width: 104px; height: auto; }

.fd-op__friend-bubble {
    position: relative;
    margin: 0 0 58px;
    padding: 8px 14px;
    border: 3px solid var(--fd-ink);
    border-radius: 22px;
    background: #fff;
    font: 400 20px/1.1 var(--fd-hand);
}

@media (min-width: 640px) {
    .fd-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 860px; }
    .fd-tile__word { font-size: clamp(18px, 2.7vw, 26px); }
    .fd-hero__lead { font-size: 21px; }
}

/*
 * Screen 1 on a laptop: Jason's composite. A fixed 1739 by 904 stage, fitted
 * whole and sat on the bottom edge, so every overlay stays where the art put it.
 * Sizes are in cqw, a share of the stage width.
 */
@media (min-width: 1000px) and (min-height: 540px) and (min-aspect-ratio: 5/4) {
    .fd-op {
        display: flex;
        align-items: flex-end;
        justify-content: center;
        height: var(--fd-screen-h);
        min-height: 0;
        padding: 0;
        background: var(--fd-scene-sky);
    }

    .fd-op__cloud,
    .fd-op__friend { display: none; }

    .fd-op__backdrop {
        display: none;
        position: absolute;
        inset: 0;
        background-position: center bottom;
        background-size: cover;
        filter: blur(18px) saturate(0.9);
        opacity: 0.6;
        transform: scale(1.08);
    }

    .fd-scene {
        flex: none;
        width: min(100%, calc(var(--fd-screen-h) * 1739 / 904));
        max-width: none;
        aspect-ratio: 1739 / 904;
        margin: 0;
        container-type: inline-size;
    }

    .fd-scene__bg {
        display: block;
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        /* the top edge melts into the sky above it on tall screens */
        -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 7%);
        mask-image: linear-gradient(to bottom, transparent 0, #000 7%);
    }

    .fd-hero { position: absolute; top: 4.3%; left: 0; right: 0; }
    .fd-hero__banner { width: 49.4%; max-width: none; }

    .fd-hero__lead {
        max-width: 54cqw;
        margin: 0.9cqw auto 0;
        font-size: 1.8cqw;
        line-height: 1.32;
    }

    .fd-tiles {
        position: absolute;
        top: 42%;
        left: 15.5%;
        width: 69.2%;
        max-width: none;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0 1.75%;
        margin: 0;
    }

    .fd-tile__word { font-size: 2.3cqw; bottom: 14.5%; }
    .fd-tile:hover .fd-tile__face { transform: translateY(-0.35cqw); }

    .fd-tile__last {
        margin-top: 0.4cqw;
        padding: 0.25cqw 0.9cqw;
        border-radius: 0.8cqw;
        font-size: max(15px, 1.12cqw);
        box-shadow: 0 0.1cqw 0.4cqw rgba(24, 60, 84, 0.12);
    }

    .fd-bubble {
        display: grid;
        place-items: center;
        position: absolute;
        top: 43.2%;
        left: 3%;
        width: 10.6%;
        aspect-ratio: 1 / 0.9;
        margin: 0;
        padding: 0.9cqw;
        border: 0.2cqw solid var(--fd-ink);
        border-radius: 50% 50% 48% 52% / 56% 52% 48% 44%;
        background: #fff;
        font: 400 1.9cqw/1.02 var(--fd-hand);
        text-align: center;
    }

    .fd-bubble::after {
        content: '';
        position: absolute;
        bottom: -0.75cqw;
        left: 60%;
        width: 1.4cqw;
        height: 1.4cqw;
        border-right: 0.2cqw solid var(--fd-ink);
        border-bottom: 0.2cqw solid var(--fd-ink);
        background: #fff;
        transform: rotate(40deg) skewX(12deg);
    }

    .fd-sign-text {
        display: grid;
        place-items: center;
        position: absolute;
        top: 18.3%;
        left: 87.2%;
        width: 12.4%;
        height: 20%;
        margin: 0;
        font: 400 2.75cqw/1 var(--fd-hand);
        -webkit-text-stroke: 0.02em currentColor;
        color: #2b1d10;
        text-align: center;
        transform: rotate(-7deg);
    }

    .fd-rock-text {
        display: grid;
        place-items: center;
        position: absolute;
        top: 79%;
        left: 84.4%;
        width: 13.8%;
        height: 14%;
        margin: 0;
        font: 400 1.95cqw/1.05 var(--fd-hand);
        color: #1f3242;
        -webkit-text-stroke: 0.015em currentColor;
        text-align: center;
        transform: rotate(-9deg);
    }
}

/* Wider than the art: the sides show a soft blur of the scene */
@media (min-width: 1000px) and (min-height: 540px) and (min-aspect-ratio: 2/1) {
    .fd-op__backdrop { display: block; }
}

/* Taller than the art: a couple of clouds in the open sky above it */
@media (min-width: 1000px) and (min-height: 540px) and (min-aspect-ratio: 5/4) and (max-aspect-ratio: 3/2) {
    .fd-op__cloud { display: block; opacity: 0.8; }
    .fd-op__cloud--a { top: 3vh; left: 8%; width: 11vw; }
    .fd-op__cloud--b { top: 7vh; right: 11%; left: auto; width: 12vw; }
}

/* Screens 2 to 4 share a quiet sky ----------------------------------------- */

.fd-level,
.fd-play,
.fd-snap,
.fd-notice {
    overflow: hidden;
    background: linear-gradient(180deg, var(--fd-sky) 0%, #f3fafd 55%, #eef7e7 100%);
}

.fd-sky { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.fd-sky img { position: absolute; height: auto; }
.fd-sky__cloud--a { top: 14px; left: 2%; width: clamp(90px, 15vw, 210px); opacity: 0.85; }
.fd-sky__cloud--b { top: 70px; right: 3%; width: clamp(100px, 17vw, 240px); opacity: 0.85; }
.fd-sky--quiet .fd-sky__cloud--a { top: auto; bottom: 5%; left: 2%; opacity: 0.5; }
.fd-sky--quiet .fd-sky__cloud--b { display: none; }
.fd-sky__hills { bottom: -6px; left: -1%; width: clamp(240px, 36vw, 540px); opacity: 0.9; }
.fd-sky__lake { bottom: -8px; right: -2%; width: clamp(240px, 34vw, 520px); opacity: 0.9; }

.fd-wrap {
    position: relative;
    z-index: 1;
    max-width: 1040px;
    margin: 0 auto;
    padding: 24px 16px 32px;
}

.fd-card {
    padding: clamp(18px, 3vw, 32px);
    border: 2px solid var(--fd-line);
    border-radius: 24px;
    background: var(--fd-card);
    box-shadow: 0 10px 30px rgba(30, 70, 100, 0.1);
}

.fd-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.fd-badge {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border: 3px solid var(--op-border);
    border-radius: 16px;
    background: var(--op-soft);
    box-shadow: 0 3px 0 var(--op-border);
    color: var(--op-accent);
    font: 800 38px/1 var(--fd-font);
}

.fd-badge--small { width: 44px; height: 44px; border-radius: 13px; font-size: 30px; }
.fd-head__kicker { margin: 0; color: var(--op-ink); font-weight: 700; font-size: 18px; }
.fd-head__title { margin: 0; font-weight: 800; font-size: clamp(26px, 4vw, 34px); line-height: 1.1; }

/* Screen 2: choose your level ---------------------------------------------- */

.fd-level__wrap { max-width: 820px; padding-top: clamp(20px, 7vh, 72px); }

.fd-levels { display: grid; grid-template-columns: 1fr; gap: 16px; }

.fd-level-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-height: 132px;
    padding: 18px 22px 20px;
    border: 3px solid var(--op-border);
    border-radius: 20px;
    background: var(--op-soft);
    box-shadow: 0 5px 0 var(--op-border);
    color: var(--fd-ink);
    text-align: left;
    cursor: pointer;
    transition: transform 0.14s ease-out, box-shadow 0.14s ease-out, border-color 0.14s;
    -webkit-tap-highlight-color: transparent;
}

.fd-level-btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--op-border); border-color: var(--op-accent); }
.fd-level-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--op-border); }
.fd-level-btn:disabled { opacity: 0.55; cursor: progress; transform: none; }

.fd-level-btn__tier { color: var(--op-ink); font-weight: 700; font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; }
.fd-level-btn__name { font-weight: 800; font-size: 32px; line-height: 1.1; }
.fd-level-btn__desc { color: var(--fd-ink-2); font-weight: 500; font-size: 19px; }

.fd-level__hint { margin: 18px 0 0; color: var(--fd-ink-2); font-weight: 500; }

@media (min-width: 640px) {
    .fd-levels { grid-template-columns: 1fr 1fr; }
}

/* Screen 3: a question. Calm, and the keypad always above the fold. -------- */

.fd-play__wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 1080px;
    min-height: var(--fd-screen-h);
    padding: 14px 16px 18px;
}

.fd-play__head { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.fd-play__title { margin: 0; font-weight: 700; font-size: clamp(20px, 2.6vw, 26px); line-height: 1.15; }
.fd-play__item { margin: 0 0 0 auto; color: var(--fd-ink-2); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.fd-time { display: flex; align-items: center; gap: 14px; }

.fd-time__track {
    flex: 1;
    height: 18px;
    overflow: hidden;
    border: 2px solid #c6d9e5;
    border-radius: 999px;
    background: #e1edf4;
}

.fd-time__fill {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: var(--op-accent);
    transform-origin: left center;
    transition: transform 0.2s linear;
}

.fd-time__text { min-width: 5.6em; margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.fd-play__body {
    display: grid;
    grid-template-areas: "question" "pad";
    gap: 14px;
    align-content: start;
}

.fd-qcard {
    grid-area: question;
    display: flex;
    flex-direction: column;
    min-height: 190px;
    padding: 14px 16px;
    border: 2px solid var(--fd-line);
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(30, 70, 100, 0.08);
    container-type: inline-size;
}

.fd-qcard__center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.fd-qrow { display: flex; align-items: center; justify-content: center; gap: 0.28em; font: 800 clamp(40px, 11vw, 96px)/1 var(--fd-font); }

/* "100 ÷ 10 = [   ]" is about 8em wide, so size it off the card, not the window */
@supports (container-type: inline-size) {
    .fd-qrow { font-size: clamp(34px, 12cqw, 100px); }
}

.fd-q {
    display: flex;
    align-items: center;
    gap: 0.28em;
    margin: 0;
    font: inherit;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.fd-q__op { color: #5b6f80; }

.fd-answer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2em;
    height: 1.3em;
    padding: 0.05em 0.2em 0;
    border: 4px solid var(--op-accent);
    border-radius: 0.2em;
    background: var(--op-soft);
    font: inherit;
    font-variant-numeric: tabular-nums;
}

.fd-answer.is-empty::after {
    content: '';
    width: 4px;
    height: 0.75em;
    border-radius: 2px;
    background: var(--fd-ink);
    animation: fd-caret 1.1s steps(1) infinite;
}

@keyframes fd-caret {
    50% { opacity: 0; }
}

.fd-count { margin: 0; color: var(--op-accent); font-weight: 800; font-size: clamp(84px, 14vw, 140px); line-height: 1; min-height: 1em; }
.fd-qcard__note { margin: 0; color: var(--fd-ink-2); font-weight: 600; font-size: 20px; }
.fd-qcard__big { margin: 0; font-weight: 800; font-size: clamp(34px, 5vw, 50px); line-height: 1.1; }

.fd-qcard__foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.fd-keys-hint { display: none; margin: 0 auto 0 0; color: var(--fd-muted); font-weight: 500; font-size: 16px; }
.fd-skip { min-width: 0; background: transparent; border-color: transparent; box-shadow: none; color: var(--fd-muted); }
.fd-skip:hover { background: #f3f8fb; }
.fd-enter { min-width: 140px; gap: 8px; }
.fd-key__label { margin-left: 6px; font-size: 20px; font-weight: 800; }

@media (hover: hover) and (pointer: fine) {
    .fd-keys-hint { display: block; }
}

.fd-pad {
    grid-area: pad;
    justify-self: center;
    width: 100%;
    max-width: 560px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    align-content: start;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.fd-key {
    display: flex;
    align-items: center;
    justify-content: center;
    /* what is left under the question card, split over 4 rows */
    height: clamp(44px, calc((var(--fd-screen-h) - 362px) / 4), 84px);
    padding: 0;
    border: 2px solid #c3d5e0;
    border-bottom-width: 6px;
    border-radius: 18px;
    background: #fff;
    color: var(--fd-ink);
    font: 700 clamp(28px, 4.4vh, 40px)/1 var(--fd-font);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.08s ease-out, background-color 0.08s;
}

.fd-key:hover { background: #f4f9fc; }
.fd-key.is-pressed,
.fd-key:active { transform: translateY(3px); border-bottom-width: 3px; background: var(--op-soft); }
.fd-key--back { background: #f0f5f8; color: var(--fd-ink-2); }
.fd-key--enter { border-color: var(--fd-primary-dark); background: var(--fd-primary); color: #fff; }
.fd-key--enter:hover { background: #0b6d66; }
.fd-key--enter.is-pressed,
.fd-key--enter:active { background: var(--fd-primary-dark); }
.fd-pad[aria-disabled="true"] .fd-key { opacity: 0.55; cursor: default; }

.fd-play__beaver { display: none; }

/* Keypad beside the question on laptops and on a phone held sideways. A tablet
   held upright keeps the phone layout, where the question gets the full width. */
@media (min-width: 900px), (min-width: 640px) and (orientation: landscape) {
    .fd-play__body {
        grid-template-columns: clamp(236px, 38%, 400px) minmax(0, 1fr);
        grid-template-areas: "pad question";
        gap: 24px;
        align-items: stretch;
    }

    .fd-qcard { padding: 18px 24px; }
    .fd-key { height: clamp(48px, calc((var(--fd-screen-h) - 156px) / 4), 96px); }

    .fd-play__beaver {
        display: block;
        position: absolute;
        right: 14px;
        bottom: 8px;
        z-index: 0;
        width: clamp(90px, 10vw, 150px);
        height: auto;
        pointer-events: none;
    }
}

@media (max-width: 899px), (max-height: 740px) {
    .fd-sky--quiet .fd-sky__cloud--a { display: none; }
}

/* Lots of height, such as an iPad on its side: sit the game in the middle */
@media (min-width: 900px) and (min-height: 860px) {
    .fd-play__wrap { justify-content: center; padding-bottom: 6vh; }
}

/* Short screens such as a phone on its side */
@media (max-height: 520px) {
    .fd-play__wrap { gap: 8px; padding-top: 8px; }
    .fd-play__head { min-height: 36px; }
    .fd-qcard { min-height: 150px; }
    .fd-key { height: clamp(44px, calc((var(--fd-screen-h) - 124px) / 4), 64px); font-size: 26px; border-bottom-width: 4px; }
    .fd-pad { gap: 6px; }
    .fd-play__beaver { display: none; }
}

/* Screen 4: your snapshot ---------------------------------------------------- */

.fd-snap__wrap { max-width: 1040px; padding-top: clamp(12px, 3vh, 24px); padding-bottom: 20px; }

.fd-snap__note { margin: -6px 0 14px; color: var(--fd-ink-2); font-weight: 600; }

.fd-empty { display: flex; align-items: center; gap: 16px; padding: 8px 0; font-weight: 600; font-size: 21px; }
.fd-empty img { flex: none; width: 110px; height: auto; }

.fd-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.fd-stat {
    padding: 14px 18px 16px;
    border: 2px solid var(--fd-line);
    border-radius: 18px;
    background: #fff;
}

.fd-stat--correct { border-color: #b9e3d5; background: #e9f7f2; }

.fd-stat__label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--fd-ink-2);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.fd-stat__value { margin: 4px 0 6px; font-weight: 800; font-size: 44px; line-height: 1.05; font-variant-numeric: tabular-nums; }

@media (max-width: 520px) {
    .fd-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .fd-stat { padding: 12px 14px 14px; }
    .fd-stat__label { font-size: 13px; letter-spacing: 0.04em; }
    .fd-stat__value { font-size: 36px; white-space: nowrap; }
    .fd-chip { font-size: 14px; }
    .fd-revisit { padding: 14px; }
}
.fd-stat__value small { color: var(--fd-ink-2); font-weight: 700; font-size: 0.5em; }

.fd-chip {
    display: inline-block;
    margin: 0;
    padding: 3px 10px;
    border-radius: 999px;
    background: #edf2f6;
    color: var(--fd-ink-2);
    font-weight: 600;
    font-size: 15px;
}

.fd-chip--good { background: #cdeee1; color: #0e5a44; }

.fd-dot { flex: none; width: 12px; height: 12px; border-radius: 4px; }
.fd-dot--fluent { background: #178a55; }
.fd-dot--slow { background: #c98a0b; }

.fd-revisit { margin-top: 20px; padding: 18px 20px; border: 2px solid var(--fd-line); border-radius: 20px; }
.fd-revisit__title { margin: 0 0 12px; color: var(--fd-ink-2); font-weight: 700; font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; }

.fd-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.fd-fact { padding: 10px 16px 12px; border: 2px solid; border-radius: 16px; }
.fd-fact--incorrect { border-color: #f3c1ba; background: #fdece9; color: #8a1c12; }
.fd-fact--effortful { border-color: #efd28f; background: #fdf3d8; color: #6b4200; }

.fd-fact__top {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.3em;
    margin: 0;
    font-weight: 800;
    font-size: 26px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.fd-fact__top s { text-decoration-thickness: 3px; }
.fd-fact__time { display: inline-flex; align-items: center; gap: 4px; margin-left: 0.2em; font-weight: 700; }
.fd-fact__time svg { flex: none; }
.fd-fact__bottom { margin: 2px 0 0; font-weight: 600; font-size: 17px; }

.fd-fact__times { white-space: nowrap; }

.fd-revisit__none { margin: 0; color: var(--fd-ink-2); font-weight: 600; }
.fd-revisit__more { margin-top: 12px; min-height: 44px; font-size: 17px; }

.fd-offer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 2px dashed var(--fd-line);
}

.fd-offer p { margin: 0; font-weight: 600; }

.fd-offer__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 6px 16px;
    border: 2px solid var(--fd-primary);
    border-radius: 999px;
    color: var(--fd-primary-dark);
    font-weight: 700;
    text-decoration: none;
}

.fd-offer__link:hover { background: #e3f4f1; }

/* No bank yet --------------------------------------------------------------- */

.fd-notice .fd-wrap,
.fd-notice__card { position: relative; z-index: 1; }
.fd-notice__card { max-width: 520px; margin: 48px auto; text-align: center; }
.fd-notice__card img { width: 140px; height: auto; }
.fd-notice__card h1 { margin: 8px 0 4px; font-size: 32px; }

.fd-noscript { margin: 24px; font-size: 20px; text-align: center; }

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

    .fd-tile:hover .fd-tile__face,
    .fd-level-btn:hover { transform: none; }
}

/* The free demo: a sign up link in the bar, and screen 5, the teacher report. */

.fd-bar__cta {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 4px 16px;
    border-radius: 999px;
    background: var(--fd-primary);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    white-space: nowrap;
}

.fd-bar__cta:hover { background: #0b6d66; }
.fd-bar__cta:focus-visible { outline: 4px solid var(--fd-focus); outline-offset: 3px; }

/* No room beside the logo and Back on a phone, and the report carries its own. */
@media (max-width: 560px) {
    .fd-bar__cta { display: none; }
}

.fd-report { padding-bottom: 24px; }
.fd-report__wrap { max-width: 900px; }

.fd-report__card {
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

.fd-report__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 24px;
    padding-bottom: 16px;
    border-bottom: 3px solid var(--fd-primary);
}

.fd-report__logo { display: block; height: 36px; width: auto; }
.fd-report__titles { flex: 1 1 260px; }
.fd-report__kicker { margin: 0; color: var(--fd-primary); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.fd-report__title { margin: 2px 0 0; font: 800 26px/1.15 var(--fd-font); color: var(--fd-ink); }
.fd-report__meta { margin: 4px 0 0; color: var(--fd-muted); font-size: 15px; }

.fd-report__note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin: 16px 0 0;
    padding: 10px 14px;
    border: 1px solid #ecd9b4;
    border-radius: 12px;
    background: #fef9f0;
    color: #5b4a24;
    font-size: 15px;
}

.fd-report__note p { margin: 0; }

.fd-report__print {
    min-height: 40px;
    padding: 4px 16px;
    border: 2px solid #c9a96a;
    border-radius: 10px;
    background: #fff;
    color: #5b4a24;
    font: 700 15px/1 'Segoe UI', system-ui, sans-serif;
    cursor: pointer;
}

.fd-report__print:hover { background: #fff7e8; }
.fd-report__print:focus-visible { outline: 4px solid var(--fd-focus); outline-offset: 3px; }

.fd-report__stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

@media (min-width: 640px) {
    .fd-report__stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.fd-report__stat { padding: 12px 14px; border: 1px solid var(--fd-line); border-radius: 14px; background: #f7fbfd; }
.fd-report__label { margin: 0; color: var(--fd-muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.fd-report__value { margin: 2px 0 0; font: 800 30px/1.1 var(--fd-font); color: var(--fd-ink); font-variant-numeric: tabular-nums; }
.fd-report__hint { margin: 2px 0 0; color: var(--fd-ink-2); font-size: 14px; }
.fd-ind--green { background: #e6f4ea; border-color: #b7dfc3; }
.fd-ind--green .fd-report__value { color: #14532d; }
.fd-ind--yellow { background: #fcf1d8; border-color: #efd48f; }
.fd-ind--yellow .fd-report__value { color: #713f12; }
.fd-ind--red { background: #fce8e8; border-color: #f3bcbc; }
.fd-ind--red .fd-report__value { color: #881337; }

.fd-report__section { margin-top: 24px; }
.fd-report__h3 { margin: 0 0 6px; font: 800 20px/1.2 var(--fd-font); color: var(--fd-ink); }
.fd-report__sub { margin: 0 0 10px; color: var(--fd-ink-2); font-size: 15px; }
.fd-report__next { margin: 0; padding: 12px 14px; border-radius: 12px; background: #e6f3f2; color: #0a4f4a; font-weight: 600; }

.fd-report__scroll { overflow-x: auto; }
.fd-report__table { width: 100%; border-collapse: collapse; font-size: 15px; }
.fd-report__table th,
.fd-report__table td { padding: 9px 10px; border-bottom: 1px solid #e3edf3; text-align: center; font-variant-numeric: tabular-nums; }
.fd-report__table thead th { background: #e6f3f2; color: #3c5061; font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; }
.fd-report__table th[scope="row"],
.fd-report__table thead th:first-child { text-align: left; }
.fd-report__fam { display: block; font-weight: 700; color: var(--fd-ink); }
.fd-report__famnote { display: block; margin-top: 2px; color: var(--fd-muted); font-size: 13px; font-weight: 400; }
.fd-report__table tr.is-miss td:last-child { color: #b42318; font-weight: 800; }
.fd-report__table tr.is-slow td:nth-child(4) { color: #9a4a05; font-weight: 800; }

@media (max-width: 520px) {
    .fd-report__table { font-size: 14px; }
    .fd-report__table th,
    .fd-report__table td { padding: 8px 4px; }
    .fd-report__table thead th { font-size: 10px; letter-spacing: 0.02em; }
    .fd-report__table th[scope="row"] { width: 40%; }
}

.fd-report__facts { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }

@media (min-width: 640px) {
    .fd-report__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.fd-report__fact {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
    padding: 10px 14px;
    border: 1px solid #f1c9c4;
    border-radius: 12px;
    background: #fff6f5;
    break-inside: avoid;
}

.fd-report__fact.is-effortful { border-color: #f2d9a8; background: #fffaf0; }
.fd-report__factq { font: 800 20px/1.2 var(--fd-font); color: var(--fd-ink); white-space: nowrap; }
.fd-report__factd { align-self: center; color: #b42318; font-weight: 700; font-size: 14px; }
.fd-report__fact.is-effortful .fd-report__factd { color: #9a4a05; }
.fd-report__factf { grid-column: 1 / -1; color: var(--fd-muted); font-size: 13px; }

.fd-report__cta {
    margin-top: 26px;
    padding: 18px;
    border: 2px solid #9fd8cc;
    border-radius: 18px;
    background: #f1faf8;
}

.fd-report__cta p { margin: 0; color: var(--fd-ink-2); }
.fd-report__ctas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.fd-report__foot { display: none; }
.fd-report__actions { flex-wrap: wrap; margin-top: 22px; }

@media print {
    @page { margin: 0.5in; }

    .fd-body { background: #fff; }
    .fd-bar,
    .fd-sky,
    .fd-report__actions,
    .fd-report__note,
    .fd-report__cta { display: none !important; }

    .fd-screen { min-height: 0; animation: none; }
    .fd-wrap { max-width: none; padding: 0; }
    .fd-report__card { border: 0; border-radius: 0; box-shadow: none; padding: 0; }
    .fd-report__stat,
    .fd-report__next,
    .fd-report__fact,
    .fd-report__table thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .fd-report__stats,
    .fd-report__next,
    .fd-report__table tr { break-inside: avoid; }
    .fd-report__h3 { break-after: avoid; }
    .fd-report__foot { display: block; margin: 18px 0 0; color: #56687a; font-size: 12px; }
}
