/* Questlings' whole look. No Bootstrap: every style the app uses is here.
 *
 * The idea: a cozy fantasy RPG to match the pixel art. A pale sky blue
 * behind everything, parchment panels with chunky pixel borders, gold for
 * coins and rewards, Fredoka (round and bold) for headings and buttons,
 * and Nunito for reading.
 */

/* --- Colours and sizes -------------------------------------------------------
 * Change a colour here and it changes everywhere it is used. */
:root {
    /* The page background: a pale sky, a little deeper at the top. */
    --bg-top: #cdeaf8;
    --bg: #eaf7fd;

    --parchment: #f7e9cc;
    --parchment-2: #ecd8b0;
    --parchment-3: #d9bf8c;
    --paper: #fffaf0;

    /* The quest board behind the notes. */
    --board: #fbfdff;
    --board-edge: #c9dfeb;

    --ink: #3b2a20;        /* text */
    --ink-soft: #5a4536;   /* small notes and hints: dark enough to read easily */
    --line: #3b2a20;       /* borders and outlines (dark in both themes) */
    --on-gold: #3b2a20;    /* text on gold, which stays bright in both themes */
    --cream: #f7e9cc;      /* light text on dark wood (the name plate) */
    --locked: #3b2a20;     /* blacked-out achievements */
    --locked-ink: #d9bf8c; /* and their text */
    --wood: #7a4f32;

    /* The creatures' own colours, used by the logo. */
    --pinky: #f489f6;
    --hoot: #94a0ba;
    --gary: #0696db;
    --navy: #04193f;

    --gold: #f4bf4f;
    --legendary: #b46cff; /* legendary purple (the hatch's perk line) */
    --gold-dark: #c08a2c;
    --gold-light: #ffe08a;
    --leaf: #62a854;
    --leaf-dark: #3f7535;
    --berry: #cf5c4f;
    --berry-dark: #963b31;

    --sky-top: #7ec8f0;
    --sky-bottom: #d6f1ff;
    --grass: #6dbb4b;
    --grass-dark: #4b8d36;

    --font-head: "Fredoka", system-ui, sans-serif;
    --font-body: "Nunito", system-ui, sans-serif;

    /* The border: an even ink outline (box-shadow, so it takes no room),
     * with soft, rounded corners from --radius; see the end of this file. */
    --px: 3px;
    --notch: 0 0 0 var(--px) var(--line);
    --radius: 12px;
    --lift: 0 5px 12px rgb(59 42 32 / 0.22);   /* a soft shadow under raised things */
}

/* --- Dark mode (Settings: Theme) --------------------------------------------
 * The same tokens, for a night sky: deep navy behind, slate panels, cream
 * text. Borders stay dark; gold stays gold (with dark text on it); the art
 * (stage, burrow, sprites) is unchanged. A small script in base.html sets
 * data-theme before the page draws, so there is no flash of the light one. */
:root[data-theme="dark"],
[data-preview-theme="dark"] {
    --bg-top: #111725;
    --bg: #182033;
    --parchment: #283044;
    --parchment-2: #333c54;
    --parchment-3: #1c2232;
    --paper: #2e374d;
    --board: #1e2638;
    --board-edge: #2f3b55;
    --ink: #f2e7d3;
    --ink-soft: #c3b8a6;
    --line: #070a12;
    --locked: #0d111b;
    --locked-ink: #5d6782;
    --gold-light: #6b5426;
    --lift: 0 5px 12px rgb(0 0 0 / 0.45);
    color-scheme: dark;
}

/* Sunset: warm peach and coral, still light. */
:root[data-theme="sunset"],
[data-preview-theme="sunset"] {
    --bg-top: #ffd9c2;
    --bg: #fff0e6;
    --parchment: #fde4d0;
    --parchment-2: #f7d0b6;
    --parchment-3: #e2ae8f;
    --paper: #fff8f2;
    --board: #fffaf7;
    --board-edge: #f1cdb7;
    --ink: #4a2626;
    --ink-soft: #6e4441;
    --line: #4a2626;
    --locked: #4a2626;
    --gold-light: #ffd08a;
}

/* Forest: deep greens for the evening, with cream text. */
:root[data-theme="forest"],
[data-preview-theme="forest"] {
    --bg-top: #10241b;
    --bg: #163020;
    --parchment: #21402d;
    --parchment-2: #2b5039;
    --parchment-3: #173223;
    --paper: #274a34;
    --board: #1b3727;
    --board-edge: #2f5a40;
    --ink: #eef3e2;
    --ink-soft: #b7cbb0;
    --line: #06120b;
    --locked: #0a1a10;
    --locked-ink: #4f7a5e;
    --gold-light: #5f6a26;
    --lift: 0 5px 12px rgb(0 0 0 / 0.45);
    color-scheme: dark;
}

/* --- Themes you collect (the Look tab) -----------------------------------------
 * Ocean (common: the theme chest or the smuggler), Candy and Autumn (rare:
 * the theme chest), and Tempest (comes with Voltrix). Same tokens as
 * the rest; each also applies to an element marked data-preview-theme, so
 * the Look tab and a prize can show a theme in its own colours. */
[data-preview-theme="light"] {
    --bg-top: #cdeaf8;
    --bg: #eaf7fd;
    --parchment: #f7e9cc;
    --parchment-2: #ecd8b0;
    --parchment-3: #d9bf8c;
    --board: #fbfdff;
    --ink: #3b2a20;
    --line: #3b2a20;
}

/* Ocean: a deep sea-blue page, sandy panels, sea-glass teal (common). */
:root[data-theme="ocean"],
[data-preview-theme="ocean"] {
    --bg-top: #1f7fa6;
    --bg: #5fb4cd;
    --parchment: #f3e2b8;
    --parchment-2: #e6cd93;
    --parchment-3: #cfae6a;
    --paper: #fff9ea;
    --board: #effaf9;
    --board-edge: #7cc7d3;
    --ink: #13344a;
    --ink-soft: #33586c;
    --line: #13344a;
    --locked: #13344a;
    --leaf: #2a9d8f;
    --leaf-dark: #1c6b62;
}

/* Lavender: a pale lilac page, warm white panels, plum buttons (common). */
:root[data-theme="lavender"],
[data-preview-theme="lavender"] {
    --bg-top: #d6c6f2;
    --bg: #f0eafb;
    --parchment: #fbf4ea;
    --parchment-2: #ebdfd0;
    --parchment-3: #d2bfa8;
    --paper: #fffbf6;
    --board: #fdfbff;
    --board-edge: #d4c5ef;
    --ink: #3e2d55;
    --ink-soft: #614f78;
    --line: #3e2d55;
    --locked: #3e2d55;
    --leaf: #8e6cc9;
    --leaf-dark: #64489a;
}

/* Slate: a cool blue-grey page, white panels, sky-blue buttons (common). */
:root[data-theme="slate"],
[data-preview-theme="slate"] {
    --bg-top: #8c9cb1;
    --bg: #c6d0dc;
    --parchment: #f3f5f8;
    --parchment-2: #dfe5ec;
    --parchment-3: #b8c3d1;
    --paper: #ffffff;
    --board: #f7f9fb;
    --board-edge: #a9b8c9;
    --ink: #26323f;
    --ink-soft: #4a5868;
    --line: #26323f;
    --locked: #26323f;
    --leaf: #4d8fc9;
    --leaf-dark: #336a99;
}

/* Candy: strawberry pink all through, pink notes on a pink board. */
:root[data-theme="candy"],
[data-preview-theme="candy"] {
    --bg-top: #ee7fb2;
    --bg: #f8c2dc;
    --parchment: #f9c6dd;
    --parchment-2: #ee9fc4;
    --parchment-3: #d77aa6;
    --paper: #f3a6c9;
    --board: #f5bad4;
    --board-edge: #e78ab5;
    --ink: #5a2741;
    --ink-soft: #7e4a63;
    --line: #5a2741;
    --locked: #5a2741;
    --leaf: #e2669f;
    --leaf-dark: #b0457a;
}

/* Autumn: rust, orange and gold on warm parchment. */
:root[data-theme="autumn"],
[data-preview-theme="autumn"] {
    --bg-top: #f2c48d;
    --bg: #fbecd9;
    --parchment: #f4dfbf;
    --parchment-2: #e8c592;
    --parchment-3: #cf9f63;
    --paper: #fff6e8;
    --board: #fffaf2;
    --board-edge: #ecc79a;
    --ink: #4a2a17;
    --ink-soft: #6d4630;
    --line: #4a2a17;
    --locked: #4a2a17;
    --leaf: #c46a2b;
    --leaf-dark: #8e4518;
}

/* Tempest: Voltrix's own, storm navy with cyan and lightning yellow. */
:root[data-theme="tempest"],
[data-preview-theme="tempest"] {
    --bg-top: #0e1630;
    --bg: #141d3c;
    --parchment: #22305c;
    --parchment-2: #2c3c70;
    --parchment-3: #18224a;
    --paper: #26356a;
    --board: #18224a;
    --board-edge: #2f4b8a;
    --ink: #eaf4ff;
    --ink-soft: #a9c2e6;
    --line: #060a18;
    --locked: #0a1022;
    --locked-ink: #4f6aa6;
    --gold: #ffe14d;
    --gold-dark: #c9a400;
    --gold-light: #6b6a2c;
    --leaf: #29b7e8;
    --leaf-dark: #1a7aa3;
    --lift: 0 5px 12px rgb(0 0 0 / 0.5);
    color-scheme: dark;
}

/* Ashfall: Ignis's own, charcoal and ash with ember-orange buttons. */
:root[data-theme="ashfall"],
[data-preview-theme="ashfall"] {
    --bg-top: #120808;
    --bg: #1c0f0d;
    --parchment: #2e1c18;
    --parchment-2: #3a2420;
    --parchment-3: #22140f;
    --paper: #34211c;
    --board: #22140f;
    --board-edge: #5a2a1a;
    --ink: #f6e6dc;
    --ink-soft: #c9a898;
    --line: #0a0404;
    --locked: #140a08;
    --locked-ink: #8a5a45;
    --gold: #ffc23d;
    --gold-dark: #c9861a;
    --gold-light: #6b4a22;
    --leaf: #e8641c;
    --leaf-dark: #a83e10;
    --lift: 0 5px 12px rgb(0 0 0 / 0.55);
    color-scheme: dark;
}

/* Starfall: Lunara's own, a plum and aubergine night with purple buttons and
 * gold, kept well away from Tempest's blue. */
:root[data-theme="starfall"],
[data-preview-theme="starfall"] {
    --bg-top: #160b26;
    --bg: #211236;
    --parchment: #34204f;
    --parchment-2: #3e2860;
    --parchment-3: #26163d;
    --paper: #3a2557;
    --board: #26163d;
    --board-edge: #5c3a85;
    --ink: #f7efff;
    --ink-soft: #c8b4e6;
    --line: #0a0412;
    --locked: #10081c;
    --locked-ink: #7a5aa0;
    --gold: #ffd76a;
    --gold-dark: #c9a032;
    --gold-light: #6b5530;
    --leaf: #9b4fd1;
    --leaf-dark: #6f2fa3;
    --lift: 0 5px 12px rgb(0 0 0 / 0.5);
    color-scheme: dark;
}

/* Starfall is legendary: its own night sky, nearly black at the top through
 * aubergine to a soft plum glow at the bottom (James: toned down a little);
 * and a tiny crescent moon where you tap something (.tap-spark.crescent,
 * static/sprites/ui/tap_crescent.png). */
:root[data-theme="starfall"] body {
    background: linear-gradient(to bottom, #0b0614 0%, #170c2a 26%, #241240 52%, #331a50 76%, #47235f 92%, #5e2c67 100%)
        fixed #170c2a;
}

/* Ashfall is legendary too: nearly black at the top, smouldering down to a
 * deep ember red at the bottom, like a fire's glow under the ash; and a
 * tiny ember where you tap something (.tap-spark.ember,
 * static/sprites/ui/tap_ember.png). */
:root[data-theme="ashfall"] body {
    background: linear-gradient(to bottom, #0b0606 0%, #160a09 26%, #2a0f0c 52%, #4a1610 76%, #6e1f12 92%, #8a2a14 100%)
        fixed #160a09;
}

/* Tempest is legendary: its own storm-sky background, nearly black navy at
 * the top through deep indigo to a faint electric blue at the bottom, like
 * the glow under a storm; and a tiny spark where you tap something
 * (app.js: tapSpark, static/sprites/ui/tap_spark.png). */
:root[data-theme="tempest"] body {
    background: linear-gradient(to bottom, #070b1c 0%, #0e1736 26%, #172453 52%, #20356f 76%, #2a4a8c 92%, #31579c 100%)
        fixed #0e1736;
}

.tap-spark {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    width: 33px;
    height: 33px;
    margin: -16px 0 0 -16px;
    background: url("../sprites/ui/tap_spark.png") 0 0 / 132px 33px no-repeat;
    image-rendering: pixelated;
    pointer-events: none;
    animation: tap-spark 0.28s steps(4) forwards;
}

.tap-spark.ember {
    background-image: url("../sprites/ui/tap_ember.png");
}

.tap-spark.crescent {
    background-image: url("../sprites/ui/tap_crescent.png");
}

@keyframes tap-spark {
    to { background-position: -132px 0; }
}

/* The phone's own "Reduce Motion" (an accessibility setting): the
 * wiggles, bounces and slides stay still (app.js: reduceMotion does the
 * same for the leaps and bursts). */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* `hidden` must always win, even over display: flex below. */
[hidden] {
    display: none !important;
}

* {
    box-sizing: border-box;
}

/* No double-tap zoom anywhere: the app is all quick taps (checking off
 * quests, the smuggler, an egg or chest to crack open), and a second tap
 * should never zoom the page. Pinch-to-zoom still works. */
html {
    touch-action: manipulation;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--ink);
    background: linear-gradient(to bottom, var(--bg-top), var(--bg) 60%) fixed var(--bg);
}

/* The page column. Narrow for the phone-sized screens, wider for the creator. */
.app {
    max-width: 760px;
    margin: 0 auto;
    padding: calc(12px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

#home-screen,
.auth,
.message-page {
    max-width: 560px;
    margin: 0 auto;
}

:focus-visible {
    outline: 3px solid var(--gold-dark);
    outline-offset: 3px;
}

/* --- Text ------------------------------------------------------------------ */

.title {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.6rem;
    margin: 4px 0 14px;
}

.center {
    text-align: center;
}

/* The top bar's logo: "Questlings" in pixel letters, in the creatures'
 * colours with their navy outline and a faint white ring that lifts it off
 * a dark theme (static/sprites/ui/logo.png, 69 x 19, at 2x). */
.logo-pixel {
    display: block;
    width: 138px;
    height: 38px;
    image-rendering: pixelated;
}

/* The log-in screen's logo: the pixel logo at 4x, one layer per letter
 * (static/sprites/ui/logo_letters.png: ten rows, each letter where it sits
 * in the word), so a wave runs along it: each letter hops one art pixel in
 * turn. Pinky, Hoot and Gary (2x, breathing: their idle animation) stand
 * behind the Q, the l and the last s, inside those letters' layers so they
 * ride them, their feet hidden a little way down behind the letter. Pinky
 * and Hoot face right, Gary turns back to face them. Their places are art
 * pixels of the logo times 4: each letter's middle, and the top of its
 * outline, plus --sink. */
.logo-big {
    position: relative;
    width: 276px;
    height: 76px;
    max-width: 100%;
    margin: 104px auto 8px;
}

.logo-letter {
    position: absolute;
    inset: 0;
    animation: letter-wave 2.6s steps(1, end) infinite;
}

/* The letter itself, in front of whoever stands on it. */
.logo-letter::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: url("../sprites/ui/logo_letters.png") 0 calc(var(--row) * -76px) / 276px 760px no-repeat;
    image-rendering: pixelated;
}

.logo-letter:nth-child(1) { --row: 0; animation-delay: 0s; }
.logo-letter:nth-child(2) { --row: 1; animation-delay: 0.12s; }
.logo-letter:nth-child(3) { --row: 2; animation-delay: 0.24s; }
.logo-letter:nth-child(4) { --row: 3; animation-delay: 0.36s; }
.logo-letter:nth-child(5) { --row: 4; animation-delay: 0.48s; }
.logo-letter:nth-child(6) { --row: 5; animation-delay: 0.6s; }
.logo-letter:nth-child(7) { --row: 6; animation-delay: 0.72s; }
.logo-letter:nth-child(8) { --row: 7; animation-delay: 0.84s; }
.logo-letter:nth-child(9) { --row: 8; animation-delay: 0.96s; }
.logo-letter:nth-child(10) { --row: 9; animation-delay: 1.08s; }

/* Up a pixel and back, then a rest while the wave runs on. */
@keyframes letter-wave {
    0% { translate: 0 0; }
    6% { translate: 0 -4px; }
    18% { translate: 0 0; }
}

.pal {
    --sink: 10px;
    position: absolute;
    width: 64px;
    height: 66px; /* frames are 32 x 33 */
    background-repeat: no-repeat;
    background-size: 256px 66px;
    image-rendering: pixelated;
    animation: pal-idle 0.9s steps(4) infinite;
}

.pal-pinky { left: calc(7px * 4 - 32px); top: calc(2px * 4 - 66px + var(--sink)); background-image: url("../sprites/craftpix/Pink_Monster/Pink_Monster_Idle_4.png"); }
.pal-hoot { left: calc(40.5px * 4 - 32px); top: calc(3px * 4 - 66px + var(--sink)); background-image: url("../sprites/craftpix/Owlet_Monster/Owlet_Monster_Idle_4.png"); animation-delay: -0.3s; }
.pal-gary { left: calc(63px * 4 - 32px); top: calc(6px * 4 - 66px + var(--sink)); background-image: url("../sprites/craftpix/Dude_Monster/Dude_Monster_Idle_4.png"); animation-delay: -0.6s; transform: scaleX(-1); --sink: 2px; }

@keyframes pal-idle {
    to { background-position: -256px 0; }
}

/* "Turn tasks into quests", under the big logo on the log-in screen. */
.tagline {
    margin: 0 0 22px;
    text-align: center;
    font: 600 1.15rem var(--font-head);
    color: var(--ink-soft);
}

.muted {
    color: var(--ink-soft);
    font-weight: 700;
}

code {
    font-size: 0.95em;
}

/* --- Panels: parchment boxes with pixel borders ------------------------------ */

.panel {
    background: var(--parchment);
    color: var(--ink);
    padding: 16px;
    margin: var(--px) var(--px) 20px;
    box-shadow: var(--notch), var(--lift);
}

/* --- Buttons -----------------------------------------------------------------
 * A darker band along the bottom (the inset shadow) makes them look raised;
 * pressing pushes them down 2 px. */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    margin: var(--px);
    padding: 10px 18px 13px;
    border: 0;
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.15rem;
    color: #fff;
    text-decoration: none;
    text-shadow: 0 2px 0 rgb(0 0 0 / 0.25);
    background: var(--leaf);
    box-shadow: inset 0 -5px 0 0 var(--leaf-dark), var(--notch);
    cursor: pointer;
}

.btn:active {
    transform: translateY(2px);
    box-shadow: inset 0 -2px 0 0 var(--leaf-dark), var(--notch);
}

.btn-gold {
    color: var(--on-gold);
    text-shadow: none;
    background: var(--gold);
    box-shadow: inset 0 -5px 0 0 var(--gold-dark), var(--notch);
}

.btn-gold:active {
    box-shadow: inset 0 -2px 0 0 var(--gold-dark), var(--notch);
}

.btn-plain {
    color: var(--ink);
    text-shadow: none;
    background: var(--parchment-2);
    box-shadow: inset 0 -5px 0 0 var(--parchment-3), var(--notch);
}

.btn-plain:active {
    box-shadow: inset 0 -2px 0 0 var(--parchment-3), var(--notch);
}

.btn-block {
    display: flex;
    width: calc(100% - var(--px) * 2);
    margin-top: 12px;
}

/* A small square button for a single symbol (edit, delete). */
.icon-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    margin: var(--px);
    border: 0;
    font-size: 1.2rem;
    color: var(--ink);
    background: var(--parchment);
    box-shadow: var(--notch);
    cursor: pointer;
}

.link-btn {
    display: block;
    min-height: 44px;
    margin: 4px auto 0;
    border: 0;
    background: none;
    font-family: var(--font-head);
    font-size: 1rem;
    color: var(--ink-soft);
    text-decoration: underline;
    cursor: pointer;
}

/* --- Form fields --------------------------------------------------------------
 * 16 px text (1rem) or bigger, or iPhones zoom in when a field is tapped. */

.label {
    display: block;
    margin: 12px 0 4px;
    font-family: var(--font-head);
    font-weight: 500;
    font-size: 1.05rem;
}

.input {
    width: calc(100% - var(--px) * 2);
    min-height: 48px;
    margin: var(--px);
    padding: 10px 12px;
    border: 0;
    font: 600 1rem var(--font-body);
    color: var(--ink);
    background: var(--paper);
    box-shadow: var(--notch), inset 0 3px 0 rgb(0 0 0 / 0.07);
}

.input:focus {
    outline: none;
    box-shadow:
        calc(var(--px) * -1) 0 0 0 var(--gold-dark),
        var(--px) 0 0 0 var(--gold-dark),
        0 calc(var(--px) * -1) 0 0 var(--gold-dark),
        0 var(--px) 0 0 var(--gold-dark),
        inset 0 3px 0 rgb(0 0 0 / 0.07);
}

.alert {
    margin: 12px var(--px);
    padding: 10px 12px;
    font-weight: 700;
    color: var(--berry-dark);
    background: #f9d9d2;
    box-shadow:
        calc(var(--px) * -1) 0 0 0 var(--berry),
        var(--px) 0 0 0 var(--berry),
        0 calc(var(--px) * -1) 0 0 var(--berry),
        0 var(--px) 0 0 var(--berry);
}

/* --- The stage: a meadow, and the character standing in it -----------------
 *
 * The background is CraftPix's nature_1 (576 x 324 art pixels), drawn
 * --bg-scale times its size and pinned to the bottom, so a phone sees the
 * ground and the tree trunks in the middle. The character's frames are
 * 32 x 33 art pixels (CraftPix's 32 x 32 plus a row for the line under the
 * feet), drawn --scale times bigger, standing --ground up from the bottom,
 * which is where the meadow's path is.
 */

.stage {
    --scale: 3;
    --bg-scale: 1;
    --ground: 40px;   /* clear of the name plate, on the meadow grass */
    position: relative;
    height: 200px;
    margin: var(--px) var(--px) 18px;
    overflow: hidden;
    /* Rounded corners and a soft shadow: the stage is a window onto the
     * meadow, softer than the pixel-notched panels. */
    border-radius: 14px;
    box-shadow: 0 0 0 3px var(--line), 0 6px 14px rgb(59 42 32 / 0.25);
    /* --scene is the equipped background (app.js: applyEquipped). */
    background: var(--scene, url("../sprites/craftpix/nature_1/orig.png")) center bottom /
        calc(576px * var(--bg-scale)) calc(324px * var(--bg-scale)) no-repeat,
        var(--sky-top);
    image-rendering: pixelated;
}

.stage-tall {
    height: 240px;
}

/* On the home screen the stage sticks to the top while the quests scroll. */
/* On the Quests page: shorter, so the board gets more of the screen. It
 * scrolls away with the page. */
.stage-home {
    --ground: 34px;
    height: 150px;
}

/* A moving background (app.js: MOVING_SCENES, moveScene): its layers over
 * the still picture, placed like it (576 x 324 art pixels, the bottom
 * middle). Only position and opacity move, never a filter (iPhone Safari
 * draws filtered, changing things only partly), and smoothly: a drifting
 * layer is two tiles wide and slides one tile's width, then starts again
 * where it looks the same. */
.scene-layers {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
}

.scene-layer {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 576px;
    height: 324px;
    margin-left: -288px;
    background: no-repeat 0 0 / 576px 324px;
    image-rendering: pixelated;
}

.scene-drift {
    width: 1152px;
    background-repeat: repeat-x;
    animation: scene-drift linear infinite;
    will-change: transform;
}

@keyframes scene-drift {
    to { transform: translateX(-576px); }
}

/* A shooting star (Lunara's Moonrise; app.js: shootStar): a pixel streak
 * sent across the sky, hidden until then. */
.scene-meteor {
    position: absolute;
    width: 44px;
    height: 14px;
    background: no-repeat 0 0 / 44px 14px;
    image-rendering: pixelated;
    opacity: 0;
}

/* Lightning and the sky's flash: hidden until a strike (app.js:
 * strikeLightning), which switches them on and off. */
.scene-bolt,
.scene-flash {
    opacity: 0;
}

/* The volcano's molten top glowing brighter and back. */
.scene-glow {
    opacity: 0;
    animation: scene-glow 3.6s ease-in-out infinite alternate;
}

@keyframes scene-glow {
    to { opacity: 0.85; }
}

/* Embers rising off the ground and fading. */
.scene-ember {
    position: absolute;
    width: 3px;
    height: 3px;
    opacity: 0;
    animation: scene-ember linear infinite;
}

@keyframes scene-ember {
    0% { opacity: 0; transform: translate(0, 0); }
    10%, 70% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--dx), -70px); }
}

/* The shadow on the ground under the character's feet. */
/* The Questling's shadow: a stepped pixel oval (shadow.png, from
 * ~/questlings-art/stage-ui/source/stage_ui.py: 16 x 4 art pixels, in four
 * sizes). It narrows a pixel each side as your Questling's body rises while
 * it breathes (data-size b; app.js: idle), shrinks as it hops up (data-size
 * 1, 2; app.js: nudge) and fades away while it's off hitting a quest
 * (.away). */
.shadow {
    position: absolute;
    left: 50%;
    bottom: calc(var(--ground) - 2px * var(--scale));
    width: calc(16px * var(--scale));
    height: calc(4px * var(--scale));
    margin-left: calc(-8px * var(--scale));
    background: url("../sprites/ui/shadow.png") 0 0 / 400% 100% no-repeat;
    image-rendering: pixelated;
    transition: opacity 0.2s;
}

.shadow[data-size="1"] { background-position: 33.333% 0; }
.shadow[data-size="2"] { background-position: 66.667% 0; }
.shadow[data-size="b"] { background-position: 100% 0; }

.shadow.away {
    opacity: 0;
}

/* The character: one frame of one sprite strip. app.js (showFrame) puts
 * all its strips on as background layers and slides the right frame into
 * view; --scale here sizes them. */
.character {
    position: absolute;
    left: 50%;
    bottom: var(--ground); /* the line under the feet on the ground, clear of the name plate */
    width: calc(32px * var(--scale));
    height: calc(33px * var(--scale));
    margin-left: calc(-16px * var(--scale));
    background-repeat: no-repeat;
    image-rendering: pixelated;
    /* --lift (in art pixels) raises the character during a jump. No
     * transition: each step snaps into place, like a frame of pixel art. */
    transform: translateY(calc(var(--lift, 0) * var(--scale) * 1px));
}

/* The name under your Questling: no plate, just the name in cream with a
 * navy outline (drawn round the letters, under them, so it's even all the
 * way round on any screen) and a navy drop below it, like the logo, the
 * hearts beside it. */
.nameplate {
    position: absolute;
    left: 50%;
    bottom: 6px;
    transform: translateX(-50%);
    max-width: 90%;
    margin: 0;
    padding: 0 4px 4px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1rem;
    color: #f7e9cc;
    -webkit-text-stroke: 4px #04193f;
    paint-order: stroke fill;
    text-shadow: 0 2px 0 #04193f;
}

/* Friendship hearts (app.js: heartsRow): five pixel hearts, 7 x 6 art
 * pixels at 2x, full, part full (in quarters) or empty. */
.hearts {
    display: inline-flex;
    gap: 1px;
    margin-left: 6px;
    vertical-align: -1px;
}

.heart {
    display: inline-block;
    width: 14px;
    height: 12px;
    background: url("../sprites/ui/hearts.png") 0 0 / 70px 12px no-repeat;
    image-rendering: pixelated;
}

/* full, then three quarters, half, a quarter, empty */
.heart.q3 { background-position: -14px 0; }
.heart.q2 { background-position: -28px 0; }
.heart.q1 { background-position: -42px 0; }
.heart.empty { background-position: -56px 0; }

.chip .hearts {
    display: flex;
    justify-content: center;
    gap: 0;
    margin: 2px 0 0;
}

/* On a Questling's card the hearts share their outlines (one art pixel
 * each), so the row is no wider than the picture and two cards still fit
 * side by side on a phone. */
.chip .heart + .heart {
    margin-left: -2px;
}

/* Hearts flying on the Quests stage (app.js: heartFlight): little ones
 * into the nameplate's hearts, bigger ones bursting up out of a new heart. */
.flying-heart {
    position: absolute;
    width: 21px;
    height: 18px;
    background-size: 105px 18px;
    pointer-events: none;
    z-index: 2;
}

.flying-heart.little {
    width: 14px;
    height: 12px;
    background-size: 70px 12px;
}

.nameplate:empty {
    display: none;
}

/* A legendary's name on the stage: its own lettering (.legend-name), with
 * the nameplate's thick outline so it reads over any background, and room
 * above for letters that rise (the nameplate clips what spills out). The
 * outline is a copy of the name behind it (app.js: legendPlate), moving
 * with it, so no letter's outline covers the letter before it. */
.nameplate:has(.legend-name) {
    padding-top: 4px;
}

.legend-plate {
    position: relative;
    display: inline-block;
}

.legend-plate .legend-outline {
    position: absolute;
    left: 0;
    top: 0;
}

.legend-plate .legend-outline b {
    color: var(--legend-ink) !important;   /* over the letters' colour animation */
    -webkit-text-stroke: 4px var(--legend-ink);
    text-shadow: 0 2px 0 var(--legend-ink);
}

/* the letters, over the outline (positioned, so they're drawn after it even
 * when they don't move, like Lunara's) */
.legend-plate .legend-name:not(.legend-outline) {
    position: relative;
}

.legend-plate .legend-name:not(.legend-outline) b {
    -webkit-text-stroke: 0;
    text-shadow: none;
}

/* The speech bubble: a paper box on the left of the stage, with a little
 * pixel tail pointing right at the character. */
/* The speech bubble, pixel art at 3x (~/questlings-art/stage-ui/source/
 * stage_ui.py): a cream box with a navy outline (four solid 3 px edges,
 * which leave its corners cut) and a shaded bottom row, the same in every
 * theme, like a game's. Drawn in CSS, not a stretched image, so it stays
 * sharp at any size or zoom. Its tail is a pixel arrow pointing at the
 * speaker (speech_tail.png). */
.speech {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    max-width: calc(50% - 40px);
    margin: 0;
    padding: 6px 9px 9px;
    background: #fffaf0;
    box-shadow: 3px 0 0 0 #04193f, -3px 0 0 0 #04193f, 0 3px 0 0 #04193f, 0 -3px 0 0 #04193f,
        inset 0 -3px 0 0 #eadfc8;
    font-family: var(--font-head);
    font-size: 0.95rem;
    line-height: 1.25;
    color: #3b2a20;
}

/* A *action* in a line, such as "happy wiggle". */
.speech-action {
    color: #7a6656;
}

/* The tail: its first two columns lie over the bubble's edge (the outline
 * and a column of cream), opening it, so even a pixel off it's cream on
 * cream. */
.speech::after {
    content: "";
    position: absolute;
    right: -27px;
    bottom: 3px;
    width: 30px;
    height: 24px;
    background: url("../sprites/ui/speech_tail.png") 0 0 / 100% 100% no-repeat;
    image-rendering: pixelated;
}

.speech.pop {
    animation: speech-pop 160ms steps(3);
}

@keyframes speech-pop {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .speech.pop {
        animation: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .character {
        transition: none;
    }

    .pal,
    .logo-letter,
    .flame,
    .smuggler,
    .burrow-pointer {
        animation: none;
    }

    .character.nudged {
        animation: none;
    }
}

/* --- Log in ------------------------------------------------------------------ */

/* Just the logo and the form, a little down from the top of the screen. */
.auth {
    max-width: 420px;
    padding-top: 12vh;
}

/* The log-in screen's links (Forgot?, Back), and good news above the form. */
.auth .btn-link {
    display: block;
    margin: 8px auto 0;
}

.auth-note {
    margin: 12px var(--px);
    padding: 10px 12px;
    font-weight: 700;
    background: var(--gold-light);
    box-shadow: var(--notch);
    border-radius: var(--radius);
}

/* A link-looking button inside a line of text (Privacy). */
.btn-link.inline,
.auth .btn-link.inline {
    display: inline;
    margin: 0;
    padding: 0;
    font-size: inherit;
}

/* Settings: your email, and whether it's confirmed. */
.email-line {
    overflow-wrap: anywhere;
}

.email-state {
    font-size: 0.9rem;
    color: var(--berry);
}

.email-state.ok {
    color: var(--leaf-dark);
}

/* --- Character creator: choices on the left, preview on the right ----------- */

.creator {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(130px, 40%);
    gap: 12px;
    align-items: start;
}

/* The preview stays in view while the choices scroll. */
.creator-preview {
    position: sticky;
    top: calc(12px + env(safe-area-inset-top));
}

/* "Saved", shown for a moment after each change in Customize. */
.saved-note {
    min-height: 1.4em;
    margin: 6px 0 0;
    text-align: center;
    font: 600 0.95rem var(--font-head);
    color: var(--leaf-dark);
    opacity: 0;
}

.saved-note.show {
    animation: saved-fade 1.6s ease-out;
}

@keyframes saved-fade {
    0%, 60% { opacity: 1; }
    100% { opacity: 0; }
}

.creator-preview .btn-block {
    margin-top: 6px;
}

/* Small phones (iPhone mini, SE): a narrower preview, so two Questling
 * cards still fit side by side in the list. Wider screens are unchanged. */
@media (max-width: 389px) {
    .creator {
        grid-template-columns: minmax(0, 1fr) minmax(104px, 32%);
        gap: 8px;
    }

    .creator .fold-body {
        padding-left: 8px;
        padding-right: 8px;
    }
}

@media (min-width: 700px) {
    .creator {
        grid-template-columns: minmax(0, 1fr) 300px;
        gap: 24px;
    }
}

/* A fold: one choice, which opens to show its options. Opening one closes
 * the others (they share name="creator"). */
.fold {
    margin: var(--px) var(--px) 12px;
    color: var(--ink);
    background: var(--parchment);
    box-shadow: var(--notch), var(--lift);
}

.fold summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 50px;
    padding: 10px 14px;
    list-style: none;
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
}

.fold summary::-webkit-details-marker {
    display: none;
}

/* The arrow at the end of each fold's title. */
.fold summary::after {
    content: "\25B8";
    color: var(--ink-soft);
}

.fold[open] summary::after {
    content: "\25BE";
}

.fold[open] summary {
    border-bottom: 3px dashed var(--parchment-3);
}

/* The current choice, shown on the right of the fold's title. */
.fold-value {
    margin-left: auto;
    max-width: 55%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font: 700 0.85rem var(--font-body);
    color: var(--ink-soft);
}

.fold-body {
    padding: 12px 12px 14px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chips + .chips {
    margin-top: 14px;
}

.chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    margin: var(--px);
    padding: 6px 12px;
    border: 0;
    font-family: var(--font-head);
    font-weight: 500;
    font-size: 1rem;
    color: var(--ink);
    background: var(--parchment-2);
    box-shadow: inset 0 -4px 0 0 var(--parchment-3), var(--notch);
    cursor: pointer;
}

/* In Settings, a setting's choices share a row evenly (and wrap their text
 * if the text is made big), rather than one left over on a line of its own. */
.settings .chips {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
}

.settings .chip {
    padding-inline: 4px;
    text-align: center;
}

.chip.active {
    color: var(--on-gold);
    background: var(--gold);
    box-shadow: inset 0 -4px 0 0 var(--gold-dark), var(--notch);
}

.chip-swatch {
    padding: 4px;
}

/* A Questling's name under its picture. */
.chip-name {
    font: 600 0.95rem var(--font-head);
}

/* A personality: the name, with a sample line under it. */
.chip-wide {
    width: calc(100% - var(--px) * 2);
    align-items: flex-start;
    text-align: left;
    padding: 8px 12px 10px;
}

.chip-sample {
    margin-top: 2px;
    font: italic 600 0.85rem var(--font-body);
    color: var(--ink-soft);
}

.chip.active .chip-sample {
    color: var(--on-gold);
}

/* A small crop of one sprite layer, for colour choices: the head (skin and
 * hair) or the body (tunic), drawn 2 times bigger. */
/* The character's stand-in while it leaps out to strike a quest (app.js:
 * strike). It sits on top of the whole page; app.js moves and sizes it with
 * transform, around the point between its feet (16, 32). */
.strike-actor {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 20;
    width: 32px;
    height: 33px;
    transform-origin: 16px 32px;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    pointer-events: none;
}

/* A burst where a hit lands (app.js: playEffect). Like the strike actor it
 * sits on top of the whole page and is placed with transform. */
.hit-effect {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 21;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    pointer-events: none;
    /* The ink outline round every spark is drawn into the sheets
     * (~/questlings-art/pixelfx/source/bake.py), not a CSS filter: iPhone
     * Safari sometimes drew a filtered, scaled effect only partly. */
}

/* A legendary Questling's dash (app.js: dash): a bolt across the screen,
 * drawn at the board's pixel size and blown up crisp. */
.dash-bolt {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    z-index: 21;
    image-rendering: pixelated;
    pointer-events: none;
}

.dash-bolt.fading {
    opacity: 0;
    transition: opacity 100ms linear;
}

/* Above the chest overlay. */
.hit-effect.on-top {
    z-index: 31;
}

.hit-effect.fading {
    opacity: 0;
    transition: opacity 100ms linear;
}

/* The Questling on the stage can be tapped (app.js: nudge). */
.character.nudgeable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.character.nudgeable:focus-visible {
    outline: 3px dashed var(--leaf);
    outline-offset: 2px;
}

/* A nudge: a quick squash and stretch from the feet. It uses `scale`, so it
 * adds to the transform that lifts the character. */
.character.nudged {
    transform-origin: 50% 100%;
    animation: nudge-squish 260ms ease-out;
}

@keyframes nudge-squish {
    0%   { scale: 1 1; }
    30%  { scale: 1.12 0.86; }
    65%  { scale: 0.94 1.08; }
    100% { scale: 1 1; }
}

/* A creature's still picture on its button in the creator. */
.creature-pic {
    --scale: 2;
    width: calc(32px * var(--scale));
    height: calc(33px * var(--scale));
    background-repeat: no-repeat;
    image-rendering: pixelated;
}

/* --- Home: top bar and quest board ------------------------------------------ */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 12px;
}

.coins {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 5px 8px;
    margin: var(--px);
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--ink);
    background: var(--parchment);
    box-shadow: var(--notch);
}

button.coins {
    border: 0;
    cursor: pointer;
}

/* One counter in the top bar (coins, keys). */
.coins .count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}


/* The counters share one button; on a narrow phone they tighten up. */
@media (max-width: 400px) {
    #open-shop {
        gap: 6px;
        padding-inline: 6px 8px;
        font-size: 1.05rem;
    }
}

/* A counter that just went up gives a little hop. */
.count.bump {
    animation: bump 300ms steps(3);
}

@keyframes bump {
    50% { translate: 0 -5px; }
}

/* A key: the first frame of pixelfx's key-glint, cropped to the key. */
.key-icon {
    display: inline-block;
    width: 22px;
    height: 16px;
    background: url("../sprites/pixelfx/key-glint.png") -23px -26px / 576px auto no-repeat;
    image-rendering: pixelated;
}

.key-icon-big {
    width: 44px;
    height: 32px;
    background-position: -46px -52px;
    background-size: 1152px auto;
    margin: 6px auto;
}

/* Gold things (a rare prize's sparkles) are the same art, tinted gold. */
.gold {
    filter: sepia(1) saturate(5) hue-rotate(-10deg) brightness(1.15);
}

/* A coin flying from a quest to the coin counter (app.js: flyCoins). */
.flying-coin {
    position: fixed;
    left: -11px; /* half the coin, so it's centred on its path */
    top: -11px;
    z-index: 22;
    pointer-events: none;
}

/* A bought key on its way to the key counter. */
.flying-key {
    position: fixed;
    left: -11px;
    top: -8px;
    z-index: 22;
    pointer-events: none;
}

/* A coin: pixel art (static/sprites/ui/coin.png, 11 x 11 at 2x; made by
 * ~/questlings-art/ui/source/coins.py), a gold coin with a star pressed in. */
.coin {
    display: inline-block;
    width: 22px;
    height: 22px;
    margin: -1px 0; /* the counter keeps its height */
    background: url("../sprites/ui/coin.png") 0 0 / 100% 100% no-repeat;
    image-rendering: pixelated;
}

/* --- The quest board ---------------------------------------------------------
 * A sheet of parchment with a faint dot grid. Notes are pinned anywhere on
 * it: app.js sets each note's left (percent) and top (pixels). */

.quests {
    margin-top: 4px;
}

.board-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.board-head .title {
    margin: 0;
    font-size: 1.35rem;
    white-space: nowrap;
}

/* The day's name between the two arrows. */
.day-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

/* The day above the board ("Today 3 left"): tap it for the calendar. One
 * dotted line under the whole thing (a border, not an underline, which
 * would break between the two text sizes). */
.day-pick {
    padding: 0 2px 2px;
    border: 0;
    border-bottom: 2px dotted var(--ink-soft);
    font: inherit;
    line-height: 1.2;
    color: inherit;
    background: none;
    cursor: pointer;
}

.day-nav .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 0.8rem;
}

.icon-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/* The once-a-day question about yesterday's unfinished quests. */
.carry {
    margin: 10px var(--px) 4px;
    padding: 10px 12px 6px;
    font-weight: 700;
    background: var(--gold-light);
    box-shadow: var(--notch);
}

.carry p {
    margin: 0 0 4px;
}

.carry-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.count {
    font: 700 0.95rem var(--font-body);
    color: var(--ink-soft);
}

.btn-small {
    min-height: 40px;
    padding: 6px 12px 9px;
    font-size: 1rem;
}

.board {
    position: relative;
    min-height: 60vh;
    margin: 10px var(--px) 20px;
    /* Plain and clean, so the notes are what stands out. */
    background: var(--board);
    border: 2px solid var(--board-edge);
    border-radius: 6px;
    /* Tapping the empty board adds a note, so no text gets selected. */
    user-select: none;
    -webkit-user-select: none;
}

.board-hint {
    margin: 0;
    padding: 30vh 24px 0;
    text-align: center;
    font: 700 1.05rem var(--font-body);
    color: var(--ink-soft);
}

/* One note, pinned to the board, holding a list of quests. NOTE_WIDTH in
 * app.js must match width. */
.note {
    position: absolute;
    width: 46%;
    padding: 14px 10px 4px;
    color: var(--ink);
    background: var(--paper);
    box-shadow: var(--notch), var(--lift);
    transform: rotate(var(--tilt, 0deg));
    transition: transform 120ms ease-out, box-shadow 120ms ease-out;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    cursor: grab;
}

/* The pin at the top of each note. */
.note::before {
    content: "";
    position: absolute;
    top: -4px;
    left: 50%;
    width: 10px;
    height: 10px;
    margin-left: -5px;
    background: var(--berry);
    box-shadow: inset -2px -2px 0 var(--berry-dark), 0 0 0 2px var(--line);
}

/* Held and being dragged: straightened, a little bigger, above the rest. */
.note.lifted {
    z-index: 10;
    transform: scale(1.06);
    box-shadow: var(--notch), 0 12px 22px rgb(59 42 32 / 0.3);
    transition: none;
    cursor: grabbing;
}

.note.editing {
    z-index: 9;
    transform: none;
    cursor: auto;
}

.note-text {
    flex: 1;
    min-width: 0;
    min-height: 28px;
    margin: 3px 0 0;
    overflow-wrap: anywhere;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.3;
    cursor: text;
}

/* Typing a quest. 16 px text, or iPhones zoom in. It always fills the
 * note's width: on a brand-new note it is not in a row, and would otherwise
 * take the browser's default width and stick out past the paper. */
.note-input {
    flex: 1;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 3px 4px;
    border: 0;
    resize: none;
    overflow: hidden;
    font: 700 1rem/1.3 var(--font-body);
    color: var(--ink);
    background: var(--parchment);
    outline: 2px dashed var(--parchment-3);
}

.note-delete {
    width: 100%;
    min-height: 36px;
    border: 0;
    font-family: var(--font-head);
    font-size: 0.95rem;
    color: var(--berry-dark);
    background: none;
    text-decoration: underline;
    cursor: pointer;
}

/* A note whose quests are all done fades a little. */
.note.done {
    opacity: 0.75;
}

/* The note's title, such as "School". */
.note-title {
    margin: 0 0 6px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--parchment-2);
    overflow-wrap: anywhere;
    font: 600 1.05rem/1.2 var(--font-head);
    cursor: text;
}

.note-title-input {
    display: block;
    width: 100%;
    margin-bottom: 6px;
    font-family: var(--font-head);
}

/* The quests on a note: one row each, a checkbox and its text. */
.note-quests {
    margin: 0;
    padding: 0;
    list-style: none;
}

.quest,
.quest-draft {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 3px 0;
}

/* A step (subquest): indented under its quest, a little smaller. */
.quest.step,
.quest-draft.step {
    padding-left: 24px;
}

.quest.step .quest-check {
    width: 22px;
    height: 22px;
}

.quest.step .quest-check:checked {
    background-size: 16px;
}

.quest.step .note-text {
    font-size: 0.92rem;
    min-height: 22px;
    margin-top: 1px;
}

/* "2/3": how many of a quest's steps are done. */
/* A repeating quest's small ↻, after its name. */
.quest-repeat {
    flex-shrink: 0;
    margin-top: 3px;
    font: 700 0.85rem var(--font-head);
    color: var(--ink-soft);
}

.step-count {
    flex-shrink: 0;
    margin-top: 5px;
    font: 600 0.8rem var(--font-head);
    color: var(--ink-soft);
}

/* While focusing, a moving background holds still (app.js: pauseScene), to
   save battery. */
body.focusing .scene-layers,
body.focusing .scene-layers * {
    animation-play-state: paused;
}

/* --- Shared notes (app.js: noteCard, openShare; blueprints/sharing.py) ------ */

/* Who a note is shared with (or who it's from), above its quests. */
.note-shared {
    margin: 0 0 6px;
    font: 600 0.8rem var(--font-head);
    color: var(--leaf-dark);
    overflow-wrap: anywhere;
}

.note.shared {
    outline: 2px dashed var(--leaf);
    outline-offset: 3px;
}

/* A friend ticked this one: on its own line, under the quest's text. */
.quest:has(.done-by) {
    flex-wrap: wrap;
}

.done-by {
    flex-basis: 100%;
    margin: -4px 0 0 36px;
    font: 600 0.75rem var(--font-head);
    color: var(--leaf-dark);
    overflow-wrap: anywhere;
}

/* Lists of friends: Settings > Friends, and the share sheet. */
.friend-list {
    display: grid;
    gap: 6px;
    margin: 8px 0;
    padding: 0;
    list-style: none;
}

.friend-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.friend-name {
    flex: 1 1 8em;
    min-width: 8em;
    font-weight: 700;
    overflow-wrap: anywhere;
    text-align: left;
}

.friend-state {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.friend-row .chip {
    margin: 0;
}

.friend-add {
    display: flex;
    gap: 6px;
}

.friend-add .input {
    flex: 1;
    min-width: 0;
}

.share-box {
    display: grid;
    gap: 8px;
}

.share-box .title {
    margin: 0;
}

/* "+ quest" and "+ title": quiet until needed, but big enough for a thumb. */
.note-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

/* Three buttons on a narrow note: a little smaller, so they fit on a line. */
.note-actions .note-btn {
    padding: 0 2px;
    font-size: 0.82rem;
}

.note-btn {
    min-height: 32px;
    padding: 0 4px;
    white-space: nowrap;
    border: 0;
    background: none;
    font: 600 0.9rem var(--font-head);
    color: var(--ink-soft);
    cursor: pointer;
}

.note.editing .note-actions {
    display: none;
}

/* A finished quest: crossed out and faded, so it reads as done even with no
 * animation. */
.quest.done .note-text {
    text-decoration: line-through;
    text-decoration-thickness: 2px;
    opacity: 0.5;
}

/* The checkbox, drawn by hand: a pixel box, green with a white tick when
 * checked. */
.quest-check {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin: var(--px);
    background: var(--paper);
    box-shadow: var(--notch);
    cursor: pointer;
}

.quest-check:checked {
    background: var(--leaf) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Cpath d='M2 8l4 4 8-8' fill='none' stroke='white' stroke-width='3' stroke-linecap='square'/%3E%3C/svg%3E") center / 20px no-repeat;
}

/* While the character is on its way to strike a quest, the quest still
 * looks unfinished; the tick appears when the hit lands. */
.quest.striking .quest-check:checked {
    background: var(--paper);
}

.quest.striking .note-text {
    text-decoration: none !important;
    opacity: 1 !important;
}

/* The hit: the note jolts. */
.note.hit {
    animation: note-hit 220ms steps(4);
}

@keyframes note-hit {
    0%   { translate: 0 0; }
    25%  { translate: 4px -2px; }
    50%  { translate: -3px 1px; }
    75%  { translate: 2px 0; }
    100% { translate: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    .note {
        transition: none;
    }

    .note.hit {
        animation: none;
    }
}

/* --- Error pages ------------------------------------------------------------- */

.message-page {
    margin-top: 40px;
    text-align: center;
}

/* --- Shop -------------------------------------------------------------------- */

.shop-group {
    margin-bottom: 24px;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-top: 10px;
}

/* --- The burrow: the whole Shop tab is the smuggler's hideout ---------------
 * One scene, 144 x 136 art pixels (static/sprites/burrow/), drawn at 3x
 * (--s). It runs edge to edge; on narrow phones its dark edges are cut
 * off. Things in it are placed in art pixels by app.js (--x, --y, --w,
 * --h) and multiplied here. Back to front: the burrow, the badger, the
 * counter, the goods, the places to tap, the pointer, his speech bubble. */
.burrow-frame {
    display: flex;
    justify-content: center;  /* wider than a phone: cut evenly off both sides */
    margin: 0 -16px 14px;
    overflow: hidden;
    background: #1b1114;      /* the burrow's darkest earth, past its edges */
}

.burrow {
    --s: 3px;
    position: relative;
    flex: none;
    width: calc(144 * var(--s));
    height: calc(136 * var(--s));
}

.burrow > * {
    position: absolute;
    image-rendering: pixelated;
}

.burrow-back,
.burrow-front {
    inset: 0;
    background: url("../sprites/burrow/back.png") 0 0 / 100% 100% no-repeat;
}

.burrow-front {
    background-image: url("../sprites/burrow/front.png");
}

.burrow-spot {
    left: calc(var(--x) * var(--s));
    top: calc(var(--y) * var(--s));
    width: calc(var(--w) * var(--s));
    height: calc(var(--h) * var(--s));
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent; /* no grey box when tapped on iPhone */
}

.burrow-spot:focus-visible {
    outline: 3px solid var(--gold-light);
    outline-offset: 2px;
}

/* The shine that sweeps across a thing for sale now and then (app.js:
 * startBurrowShine): a soft band of light, masked to the thing's own shape
 * (--mask), so the wall behind never lights up. */
.spot-shine {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    -webkit-mask: var(--mask) 0 0 / 100% 100% no-repeat;
    mask: var(--mask) 0 0 / 100% 100% no-repeat;
}

.spot-shine::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -70%;
    width: 50%;
    background: linear-gradient(105deg, transparent, rgb(255 255 255 / 0.65) 50%, transparent);
}

.spot-shine.go::before {
    animation: spot-shine 0.9s ease-in-out;
}

@keyframes spot-shine {
    to { left: 125%; }
}

.burrow-good {
    background: 0 0 / 100% 100% no-repeat;
}

/* A jar: the glass and lid behind, the effect playing in the middle
 * (app.js: playInJar), the glass's shine in front. */
.burrow-jar {
    background-image: url("../sprites/burrow/jar_back.png");
}

.burrow-jar::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url("../sprites/burrow/jar_front.png") 0 0 / 100% 100% no-repeat;
    image-rendering: pixelated;
}

.jar-inside {
    position: absolute;
    left: calc(2 * var(--s));
    top: calc(5 * var(--s));
    width: calc(11 * var(--s));
    height: calc(11 * var(--s));
    overflow: hidden;
}

.jar-fx {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    image-rendering: pixelated;
}

/* The pointer bobs over whatever you tapped. */
.burrow-pointer {
    left: calc(var(--x) * var(--s));
    top: calc(var(--y) * var(--s));
    width: calc(7 * var(--s));
    height: calc(5 * var(--s));
    background: url("../sprites/burrow/pointer.png") 0 0 / 100% 100% no-repeat;
    pointer-events: none;
    animation: pointer-bob 0.8s steps(2) infinite;
}

@keyframes pointer-bob {
    50% { translate: 0 calc(var(--s) * -1); }
}

/* His speech bubble, above his head, with the tail pointing down at him. */
.burrow-speech {
    top: auto;
    left: calc(72 * var(--s));
    bottom: calc(71 * var(--s));
    translate: -50% 0;
    width: max-content;
    max-width: 170px;
    font-size: 0.9rem;
    text-align: center;
    pointer-events: none;
}

/* The tail turned to point down at him, its open side over the bubble's
 * bottom edge. */
.burrow-speech::after {
    right: auto;
    left: calc(50% - 15px);
    bottom: -24px;
    transform: rotate(90deg);
}

/* The smuggler, a badger, standing behind his counter. He breathes slowly (4
 * frames, 1.6 seconds) and plays his sell animation when you buy:
 * 5 frames, timed 120, 110, 140, 500 (the wink) and 160 ms. Each frame is
 * 48 x 48. */
.smuggler {
    left: calc(48 * var(--s));
    top: calc(64 * var(--s));
    width: calc(48 * var(--s));
    height: calc(48 * var(--s));
    /* Both strips are on him at once (idle first, then selling) and only
     * slide; swapping the picture made iPhone Safari blank him for a frame. */
    background-image: url("../sprites/smuggler/Smuggler_Idle_4.png"), url("../sprites/smuggler/Smuggler_Sell_5.png");
    background-size: 400% 100%, 500% 100%;
    background-position: 0 0, -9999px 0;
    background-repeat: no-repeat;
    transform-origin: 50% 100%;
    animation: smuggler-idle 1.6s steps(4) infinite;  /* slower than the Questlings: a big, unhurried badger */
}

.smuggler.selling {
    animation: smuggler-sell 1.03s steps(1) forwards;
}

/* Tapped: a small squash from his feet, smaller than a Questling's nudge. */
.smuggler.poked {
    animation: smuggler-idle 1.6s steps(4) infinite, smuggler-poke 280ms ease-out;
}

@keyframes smuggler-poke {
    0%   { scale: 1 1; }
    35%  { scale: 1.05 0.94; }
    70%  { scale: 0.98 1.03; }
    100% { scale: 1 1; }
}

@keyframes smuggler-idle {
    from { background-position: 0 0, -9999px 0; }
    to { background-position: calc(-192 * var(--s)) 0, -9999px 0; }
}

@keyframes smuggler-sell {
    0% { background-position: -9999px 0, 0 0; }
    11.7% { background-position: -9999px 0, calc(-48 * var(--s)) 0; }
    22.3% { background-position: -9999px 0, calc(-96 * var(--s)) 0; }
    35.9% { background-position: -9999px 0, calc(-144 * var(--s)) 0; }
    84.5%, 100% { background-position: -9999px 0, calc(-192 * var(--s)) 0; }
}

/* The deal panel under the scene: the thing the pointer is on. */
.deal-card {
    grid-template-columns: 96px 1fr;
    align-items: center;
    gap: 12px;
}

.deal-card .shop-pic {
    height: 72px;
}

.deal-info {
    display: grid;
    gap: 6px;
}

/* "New stock in 5h 12m", just under the burrow. */
.burrow-timer {
    width: fit-content;
    margin: -4px auto 12px;
    padding: 3px 12px 4px;
    font: 600 0.95rem var(--font-head);
    color: var(--cream);
    background: var(--wood);
    border-radius: var(--radius);
    box-shadow: var(--notch);
    font-variant-numeric: tabular-nums;
}

.burrow-hint {
    text-align: center;
}

.shop-card {
    display: grid;
    gap: 8px;
    align-content: start;
    padding: 10px;
    margin: var(--px);
    background: var(--parchment);
    box-shadow: var(--notch);
}

/* Two buttons side by side in the deal panel (a key: buy and sell). */
.deal-buttons {
    display: flex;
    gap: 8px;
}

.deal-buttons > * {
    flex: 1;
    min-width: 0;
}

/* Too few coins to buy it yet: the price shows, faded. */
.shop-card .btn-gold:disabled {
    opacity: 0.5;
    cursor: default;
}

/* The item in use gets a gold background. */
.shop-card.equipped {
    background: var(--gold-light);
}

.shop-card h3 {
    margin: 0;
    font: 600 1.05rem/1.2 var(--font-head);
}

.shop-pic {
    height: 84px;
    box-shadow: var(--notch);
    margin: var(--px);
    image-rendering: pixelated;
}

.shop-pic-background {
    background-size: cover;
    background-position: center bottom;
}

/* A legendary background's picture: its lower part (the bottom 210 of 324),
 * past the empty top its moved-down clouds, moon or volcano leave. */
.shop-pic-background.shop-pic-low {
    background-size: auto 155%;
}

/* An effect's picture is a blank note-coloured square; tapping it plays the
 * effect on it. */
.shop-pic-effect {
    position: relative;
    background: var(--board);
    cursor: pointer;
}

/* Random: a big question mark where the effect would play. */
.shop-pic-random::before {
    content: "?";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font: 700 2.4rem var(--font-head);
    color: var(--gold);
    -webkit-text-stroke: 0.08em var(--line);
    paint-order: stroke fill;
}

/* The effect's fullest frame, small, above "Tap to play" (app.js: drawStill). */
.fx-still {
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(100% - 12px);
    height: calc(100% - 30px);
    object-fit: scale-down;     /* centred, and shrunk only if it doesn't fit */
    image-rendering: pixelated;
    pointer-events: none;
    transition: opacity 0.15s;
}

.shop-pic-effect.playing .fx-still {
    opacity: 0;
}

.shop-pic-effect::after {
    content: "Tap to play";
    position: absolute;
    inset: auto 0 6px;
    text-align: center;
    font: 600 0.8rem var(--font-head);
    color: var(--ink-soft);
}

/* --- Tab bar ------------------------------------------------------------------
 * Fixed along the bottom, like a phone app, clear of the iPhone's home bar.
 * The page leaves room for it (body.has-tabs). */
/* Moving a quest: it glows; every other quest is a place to put it (a
 * dashed line on top shows where), and each note's buttons become "Put at
 * bottom". Nothing changes size. */
.quest.moving {
    border-radius: 6px;
    background: color-mix(in srgb, var(--gold) 45%, transparent);
}

.quest:has(> .move-above) {
    position: relative;
}

.move-above {
    position: absolute;
    inset: -3px 0 0;
    padding: 0;
    border: 0;
    border-top: 3px dashed var(--gold);
    background: transparent;
    cursor: pointer;
}

.moving-quest .note-actions > .note-btn {
    visibility: hidden;
}

.note-actions:has(> .move-bottom) {
    position: relative;
}

.move-bottom {
    position: absolute;
    inset: 0;
    border: 2px dashed var(--gold);
    border-radius: 6px;
    font: 600 0.85rem var(--font-head);
    color: var(--ink);
    background: var(--paper);
    cursor: pointer;
}

/* The welcome tour: everything dims except a spotlight on one part (the
 * spot's huge shadow is the dimming), with a card of explanation. */
.tour {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.tour[hidden] {
    display: none;
}

.tour-spot {
    position: fixed;
    border-radius: var(--radius);
    box-shadow: 0 0 0 9999px rgba(20, 14, 10, 0.62), 0 0 0 3px var(--gold);
    pointer-events: none;
    transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
}

.tour-card {
    position: fixed;
    left: 16px;
    right: 16px;
    max-width: 420px;
    margin: 0 auto;
    padding: 14px 14px 10px;
    color: var(--ink);
    background: var(--parchment);
    border-radius: var(--radius);
    box-shadow: var(--notch), var(--lift);
    transition: top 0.25s ease;
}

.tour-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tour-pal {
    flex-shrink: 0;
}

.tour-text {
    margin: 0;
    font-weight: 600;
    line-height: 1.4;
}

.tour-buttons {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
}

.tour-count {
    font: 600 0.85rem var(--font-head);
    color: var(--ink-soft);
}

/* A tap step: the lit tab's gold ring pulses, to say "tap here". */
.tour-spot.tap {
    animation: tour-tap 1.1s ease-in-out infinite;
}

@keyframes tour-tap {
    50% { box-shadow: 0 0 0 9999px rgba(20, 14, 10, 0.62), 0 0 0 6px var(--gold); }
}

@media (prefers-reduced-motion: reduce) {
    .tour-spot,
    .tour-card {
        transition: none;
    }

    .tour-spot.tap {
        animation: none;
    }
}

/* "Quest deleted · Undo", just above the tab bar. */
.undo-bar {
    position: fixed;
    left: 50%;
    bottom: calc(84px + env(safe-area-inset-bottom));
    z-index: 16;
    display: flex;
    align-items: center;
    gap: 14px;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 8px 8px 8px 16px;
    transform: translateX(-50%);
    font-weight: 700;
    color: var(--cream);
    background: var(--wood);
    border-radius: var(--radius);
    box-shadow: var(--notch), var(--lift);
}

.undo-bar[hidden] {
    display: none;
}

.cal-pick {
    margin: 0 0 8px;
    font: 600 1rem var(--font-head);
    overflow-wrap: anywhere;
}

.undo-btn {
    min-height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: calc(var(--radius) - 4px);
    font: 700 1rem var(--font-head);
    color: var(--on-gold);
    background: var(--gold);
    cursor: pointer;
}

/* The move bar: its message on top, the buttons in a row under it. */
.move-bar {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 10px;
    padding: 10px;
}

.move-bar span {
    flex-basis: 100%;
    text-align: center;
}

.undo-btn {
    white-space: nowrap;
}

.undo-btn.undo-btn-plain {
    color: var(--cream);
    background: rgb(255 255 255 / 0.16);
}

.tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 4px max(4px, env(safe-area-inset-left)) calc(4px + env(safe-area-inset-bottom))
        max(4px, env(safe-area-inset-right));
    background: var(--parchment);
    box-shadow: 0 calc(var(--px) * -1) 0 0 var(--line);
}

.tabs button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    padding: 4px 2px;
    border: 0;
    font: 600 0.78rem var(--font-head);
    color: var(--ink-soft);
    background: none;
    cursor: pointer;
}

/* The number on Settings when someone wants to be friends. */
.tabs button {
    position: relative;
}

.tab-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 22px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font: 700 0.72rem/18px var(--font-body);
    color: #fff;
    background: var(--berry);
    box-shadow: 0 0 0 2px var(--paper);
}

/* Settings' Friends, opened while a request waits: a short glow. */
.panel.attention {
    animation: attention 1.2s ease-in-out 2;
}

@keyframes attention {
    50% { box-shadow: 0 0 0 4px var(--gold), var(--notch); }
}

@media (prefers-reduced-motion: reduce) {
    .panel.attention {
        animation: none;
        box-shadow: 0 0 0 4px var(--gold), var(--notch);
    }
}

.tabs button[aria-current="page"] {
    color: var(--ink);
    background: var(--gold-light);
    box-shadow: var(--notch);
}

.tab-icon {
    width: 26px;
    height: 26px;
    image-rendering: pixelated;
}

/* The chest and your Questling, shrunk to tab-icon size. */
.tabs .chest-icon {
    width: 27px;
    height: 20px;
    margin: 3px 0;
    background-position: -74px -78px;
    background-size: 1760px auto;
}

.tabs .creature-pic {
    --scale: 0.8;
    width: calc(32px * var(--scale));
    height: calc(33px * var(--scale));
}

body.has-tabs .app {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

.page-title {
    margin: 4px var(--px) 12px;
}

/* --- Goal bar (Quests tab) ----------------------------------------------------
 * Today at a glance, with no words: a bar that fills as set quests are
 * done, a marker per milestone, and the streak with a flame. */
.goal-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    width: calc(100% - var(--px) * 2);
    min-height: 44px;
    margin: 8px var(--px) 0;
    padding: 8px 14px;
    border: 0;
    border-radius: 14px;
    background: var(--parchment);
    box-shadow: 0 0 0 2px var(--line), 0 4px 10px rgb(59 42 32 / 0.18);
    cursor: pointer;
}

/* The bar, in pixel art (made by ~/questlings-art/goals/source/goals.py):
 * a navy frame with cut corners (goal_frame.png as a border image), the
 * theme's own colour inside with a shadow along the top, and gold filling
 * it as today's set quests are done (a light top row, a shaded bottom one).
 * Everything at 3x. On a dark theme the frame has the logo's faint ring. */
.goal-track {
    position: relative;
    flex: 1;
    height: 18px;
    margin-right: 8px;
    border: 3px solid transparent;
    border-image: url("../sprites/ui/goal_frame.png") 1 / 3px;
    background: var(--parchment-2) padding-box;
    box-shadow: inset 0 3px 0 rgb(0 0 0 / 0.14);
    image-rendering: pixelated;
}

:root:is([data-theme="dark"], [data-theme="forest"], [data-theme="tempest"], [data-theme="ashfall"], [data-theme="starfall"]) .goal-track {
    height: 24px; /* the ring's 3px each side on top of the light frame's */
    border-width: 6px;
    border-image: url("../sprites/ui/goal_frame_dark.png") 2 / 6px;
}

.goal-track.big {
    height: 24px;
    margin: 14px 12px 8px 0;
}

:root:is([data-theme="dark"], [data-theme="forest"], [data-theme="tempest"], [data-theme="ashfall"], [data-theme="starfall"]) .goal-track.big {
    height: 30px;
}

.goal-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: url("../sprites/ui/goal_fill_4.png") 0 0 / 3px 12px repeat-x;
    image-rendering: pixelated;
}

.goal-track.big .goal-fill {
    background-image: url("../sprites/ui/goal_fill_6.png");
    background-size: 3px 18px;
}

.goal-fill[style*="width: 0%"] {
    display: none;
}

/* A milestone: a pixel star (goal_star.png: dull, then lit), lit once
 * reached. */
.goal-mark {
    position: absolute;
    top: 50%;
    width: 27px;
    height: 27px;
    margin: -13.5px 0 0 -13.5px;
    background: url("../sprites/ui/goal_star.png") 0 0 / 54px 27px no-repeat;
    image-rendering: pixelated;
}

.goal-mark.reached {
    background-position: -27px 0;
}

/* The last star (all done) sits inside the end of the bar, not over its
 * frame. */
.goal-mark:last-child {
    margin-left: -27px;
}

.goal-streak {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font: 600 1.15rem var(--font-head);
    color: var(--ink);
}

.goal-streak.none {
    color: var(--ink-soft);
}

/* The flame is taller than the bar's text: it reaches into the bar's
 * padding, so the bar stays its old height. */
.goal-streak .flame {
    margin-block: -8px;
}

/* The streak flame: a wisp of flame with our navy outline (streak_wisp.png,
 * 4 frames of 15 x 30, from Idylwild's Chromatic Campfires, CC0); from a
 * week's streak it burns hotter, blue (streak_wisp_blue.png); and for a day not
 * reached, a grey, still one (streak_wisp_unlit.png). Made by
 * ~/questlings-art/streak/source/streak.py. At 2x. */
.flame {
    display: inline-block;
    width: 30px;
    height: 60px;
    background: url("../sprites/ui/streak_wisp.png") 0 0 / 120px 60px no-repeat;
    image-rendering: pixelated;
    animation: flame-burn 0.6s steps(4) infinite;
}

.goal-streak.none .flame,
.flame-slot:not(.lit) .flame {
    background-image: url("../sprites/ui/streak_wisp_unlit.png");
    background-size: 30px 60px;
    animation: none;
}

.goal-streak.week .flame,
.flames.week .flame-slot.lit .flame {
    background-image: url("../sprites/ui/streak_wisp_blue.png");
}

@keyframes flame-burn {
    to { background-position: -120px 0; }
}

/* --- Goals ---------------------------------------------------------------------- */
/* Today's goals and the streak are small panels, always shown; friendship
 * and achievements are folds (app.js: drawLog). */

#log .fold,
.log-section.panel {
    margin: var(--px) var(--px) 12px;
}

.log-section.panel {
    padding: 12px 14px;
}

.log-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.log-section .title {
    margin: 0;
    font-size: 1.2rem;
}

.log-head-value {
    font: 700 0.9rem var(--font-body);
    color: var(--ink-soft);
}

.log-big {
    margin: 4px 0;
    font: 600 1.05rem var(--font-head);
}

.log-note {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.log-coins {
    font: 600 0.95rem var(--font-head);
    color: var(--gold-dark);
}

/* Each milestone (Half, three quarters, All) and what it pays, on its
 * mark, under the bar. */
.goals-panel .log-big {
    margin: 2px 0 0;
}

.goals-panel .goal-track.big {
    margin: 14px 18px 24px 0;
}

.goal-mark-coins {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    font: 700 0.75rem var(--font-head);
    color: var(--gold-dark);
    white-space: nowrap;
}

.goal-mark.reached .goal-mark-coins {
    color: var(--leaf-dark);
}

/* The streak: seven flames, lit for each day of it. */
.flames {
    display: flex;
    gap: 8px;
    margin: 6px 0 0;
}

/* Each in its own time, so the row doesn't move in step. */
.flame-slot:nth-child(2) .flame { animation-delay: -0.25s; }
.flame-slot:nth-child(3) .flame { animation-delay: -0.4s; }
.flame-slot:nth-child(4) .flame { animation-delay: -0.95s; }
.flame-slot:nth-child(5) .flame { animation-delay: -0.15s; }
.flame-slot:nth-child(6) .flame { animation-delay: -0.6s; }
.flame-slot:nth-child(7) .flame { animation-delay: -1.1s; }



/* Friendship: today's two, then your Questlings with their hearts. */
.friend-today {
    margin: 0 0 10px;
    font-weight: 700;
}

.friend-check {
    color: var(--ink-soft);
    white-space: nowrap;
}

.friend-check.done {
    color: var(--leaf-dark);
}

.friend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}

.friend-card {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 6px;
    border: 0;
    border-radius: var(--radius);
    background: var(--parchment-2);
    color: var(--ink);
    font: inherit;
    cursor: pointer;
}

/* the one whose today is shown */
.friend-card.picked {
    box-shadow: inset 0 0 0 3px var(--gold);
}

.friend-card:focus-visible {
    outline: 3px solid var(--line);
    outline-offset: 2px;
}

/* your Questling */
.friend-yours {
    font: 700 0.7rem var(--font-body);
    color: var(--ink-soft);
}

.friend-card h3 {
    margin: 0;
    font: 600 0.95rem var(--font-head);
}

.friend-card .hearts {
    margin: 0;
}


.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px;
    margin-top: 8px;
}

.achievement {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: var(--px);
    padding: 8px 10px;
}

.achievement-text {
    min-width: 0;
}

.achievement h4 {
    margin: 0 0 2px;
    font: 600 1.05rem var(--font-head);
}

.achievement-group {
    margin: 14px 0 0;
    font: 600 1.1rem var(--font-head);
    color: var(--ink-soft);
}

/* A badge: a 20 x 24 pixel medal (static/sprites/badges/), drawn at 2x on
 * the wall and 5x when it is earned. */
.badge {
    flex: none;
    width: 40px;
    height: 48px;
    background: center / 100% 100% no-repeat;
    image-rendering: pixelated;
}

.achievement.locked .badge {
    filter: brightness(0) opacity(0.35);
}

.achievement.locked.secret .badge {
    filter: grayscale(0.6) opacity(0.6);
}

.achievement p {
    margin: 0 0 4px;
    font-size: 0.9rem;
}

.achievement.unlocked {
    background: var(--gold-light);
}

/* Not reached yet: blacked out, so it is clear there is more to get. */
.achievement.locked {
    background: var(--locked);
    color: var(--locked-ink);
}

.achievement.locked .log-coins {
    color: var(--gold);
}

/* The celebration. */
.achievement-box {
    display: grid;
    justify-items: center;
    gap: 6px;
}

.achievement-box .title {
    margin: 0;
}

.badge-big {
    width: 100px;
    height: 120px;
    margin: 6px 0;
}

.badge-big.pop {
    animation: badge-pop 0.5s steps(6) both;
}

@keyframes badge-pop {
    0% { scale: 0.2; }
    60% { scale: 1.15; }
    100% { scale: 1; }
}

.achievement-goal {
    margin: 0;
    color: var(--ink-soft);
}

.achievement-reward {
    margin: 4px 0 6px;
    font: 600 1.1rem var(--font-head);
    color: var(--gold-dark);
}

.achievement-box .btn-block {
    justify-self: stretch;
}

.settings p {
    margin: 0 0 12px;
}

.shop-blurb {
    margin: 4px 0 0;
    color: var(--ink-soft);
}

.shop-note {
    margin: 0;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

/* A chest: the first frame of pixelfx's chest-open, cropped to the chest. */
.chest-icon {
    width: 54px;
    height: 40px;
    margin: 4px auto;
    background: url("../sprites/pixelfx/chest-open.png") -148px -156px / 3520px auto no-repeat;
    image-rendering: pixelated;
}

/* Opening a chest: the page dims and the chest opens in the middle. */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgb(0 0 0 / 0.55);
    overscroll-behavior: contain;
}

/* While a pop-up is open the page behind it stays put: it can't be scrolled,
 * and scrolling to the end of a pop-up's own text (the rewards sheet) doesn't
 * carry on into the page. */
html:has(.overlay:not([hidden])),
html:has(.overlay:not([hidden])) body {
    overflow: hidden;
}

.overlay-box {
    overscroll-behavior: contain;
}

.overlay-box {
    width: min(340px, 100%);
    padding: 16px;
    text-align: center;
    background: var(--parchment);
    box-shadow: var(--notch);
}

/* --- The repeat sheet (app.js: openRepeat) -------------------------------- */
.repeat-box {
    width: min(360px, 100%);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    text-align: left;
}

.repeat-title {
    margin: 0 0 4px;
    font-size: 1.15rem;
    text-align: center;
    overflow-wrap: anywhere;
}

.repeat-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.repeat-days .chip {
    min-width: 0;
    margin: 0;
    padding: 6px 0;
}

.repeat-quick {
    display: flex;
    gap: 6px;
    margin: 8px 0;
}

.repeat-quick .chip {
    flex: 1;
    margin: 0;
    padding: 6px 4px;
    font-size: 0.9rem;
}

.repeat-monthly {
    display: flex;
    width: 100%;
    margin: 0;
    font-size: 0.9rem;
}

.repeat-until-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.repeat-until-row .input {
    flex: 1;
    min-width: 0;
}

.repeat-until.off {
    opacity: 0.45;
}

.repeat-preview {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin: 12px 0;
    text-align: center;
}

.repeat-cell {
    padding: 4px 0;
    border-radius: 6px;
    font: 600 0.8rem var(--font-head);
    color: var(--ink-soft);
    background: var(--paper);
}

.repeat-cell.past {
    opacity: 0.4;
}

.repeat-cell.today {
    box-shadow: inset 0 0 0 2px var(--ink);
}

.repeat-cell.on {
    color: var(--on-gold);
    background: var(--gold);
}

/* --- The calendar (app.js: openCalendar) ---------------------------------- */
.calendar-box {
    width: min(360px, 100%);
}

.cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cal-head .title {
    margin: 0;
    font-size: 1.2rem;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin: 12px 0 8px;
}

.cal-wd {
    font: 600 0.75rem var(--font-head);
    color: var(--ink-soft);
}

.cal-day {
    position: relative;
    aspect-ratio: 1;
    padding: 0 0 6px;
    border: 0;
    border-radius: 8px;
    font: 600 0.95rem var(--font-head);
    color: var(--ink);
    background: var(--paper);
    cursor: pointer;
}

.cal-day:disabled {
    opacity: 0.3;
    cursor: default;
}

/* a dot under the number: quests that day; a ring: planned ahead */
.cal-day.has::after,
.cal-day.planned::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 5px;
    width: 6px;
    height: 6px;
    margin-left: -3px;
    border-radius: 50%;
    background: var(--leaf);
}

.cal-day.planned::after {
    background: none;
    box-shadow: inset 0 0 0 1.5px var(--leaf);
}

/* every set quest done: gold */
.cal-day.clear {
    color: var(--on-gold);
    background: var(--gold);
}

/* A streak day (two or more in a row): a little pixel flame, top left,
 * with the number nudged right to clear it. */
.cal-day.streak {
    padding-left: 6px;
}

.cal-day.streak::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 12px;
    background: url("../sprites/ui/flame.png") 0 0 / 100% 100% no-repeat;
    image-rendering: pixelated;
}

.cal-day.today {
    box-shadow: inset 0 0 0 2px var(--ink);
}

.cal-day.viewing {
    color: var(--cream);
    background: var(--wood);
}

.cal-key {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0 0 12px;
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.cal-key span {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.cal-key-dot { background: var(--leaf); }
.cal-key-clear { margin-left: 8px; border-radius: 3px !important; background: var(--gold); }
.cal-key-plan { margin-left: 8px; box-shadow: inset 0 0 0 1.5px var(--leaf); }
.cal-key .cal-key-streak { margin-left: 8px; width: 5px; height: 6px; border-radius: 0; background: url("../sprites/ui/flame.png") 0 0 / 100% 100%; image-rendering: pixelated; }

.cal-hint {
    margin: -6px 0 12px;
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.cal-add {
    margin: 0 0 12px;
    text-align: left;
}

.cal-add-row {
    display: flex;
    gap: 8px;
}

.cal-add-row .input {
    flex: 1;
    min-width: 0;
}

.cal-buttons {
    display: flex;
    gap: 8px;
}

.cal-buttons .btn {
    flex: 1;
}

/* --- Opening a chest (app.js: openChest, showPrize) ---------------------- */
.prize-box {
    width: min(360px, 100%);
}

/* The chest, before it opens: pixelfx's chest-open first frame at 2.5x
 * (the same size it opens at), dropping in, then rattling every so often. */
.prize-chest-spot {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 14px;
    height: 220px;
}

.prize-chest {
    width: 68px;
    height: 50px;
    padding: 0;
    border: 0;
    background: url("../sprites/pixelfx/chest-open.png") -185px -195px / 4400px auto no-repeat;
    image-rendering: pixelated;
    cursor: pointer;
}

.prize-chest.dropping {
    animation: chest-drop 0.5s steps(10) both, chest-rattle var(--rattle, 1.4s) 0.7s infinite;
}

/* Each tap that doesn't open it brings it closer (bigger) and makes it
 * rattle faster and harder. */
.prize-chest {
    transition: scale 0.18s ease-out;
}
.prize-chest[data-strain="1"] { --rattle: 0.7s; --shake: 6px; scale: 1.35; }
.prize-chest[data-strain="2"] { --rattle: 0.35s; --shake: 10px; scale: 1.75; }

@keyframes chest-drop {
    0% { transform: translateY(-180px); }
    60% { transform: translateY(0); }
    78% { transform: translateY(-14px); }
    100% { transform: translateY(0); }
}

@keyframes chest-rattle {
    0%, 66%, 100% { translate: 0 0; }
    70% { translate: calc(var(--shake, 3px) * -1) 0; }
    76% { translate: var(--shake, 3px) 0; }
    82% { translate: calc(var(--shake, 3px) * -1) 0; }
    88% { translate: var(--shake, 3px) 0; }
}

/* NEW! in the logo's bouncing letters; RARE! all in gold. */
.prize-banner {
    margin: 0;
    font: 700 2.4rem/1.1 var(--font-head);
}

.prize-banner > b,
.banner-word > b {
    display: inline-block;
    -webkit-text-stroke: 0.09em var(--navy);
    paint-order: stroke fill;
    text-shadow: 0 0.07em 0 var(--navy);
    animation: banner-bounce 0.8s steps(2) infinite;
}

.prize-banner > b:nth-child(even), .banner-word > b:nth-child(even) { animation-delay: -0.4s; }
.prize-banner > b:nth-child(4n+1), .banner-word > b:nth-child(4n+1) { color: var(--pinky); }
.prize-banner > b:nth-child(4n+2), .banner-word > b:nth-child(4n+2) { color: var(--hoot); }
.prize-banner > b:nth-child(4n+3), .banner-word > b:nth-child(4n+3) { color: var(--gary); }
.prize-banner > b:nth-child(4n+4), .banner-word > b:nth-child(4n+4) { color: var(--gold); }
.prize-banner.rare > b,
.prize-banner.rare .banner-word > b { color: var(--gold-light); }

@keyframes banner-bounce {
    0%, 100% { transform: translateY(-0.05em) rotate(-5deg); }
    50% { transform: translateY(0.05em) rotate(5deg); }
}

.prize-name {
    font-size: 1.5rem;
}

/* Under a legendary Questling as it hatches: what it comes with. */
.prize-perk {
    margin: 8px 0 0;
    font: 700 0.95rem var(--font-head);
    text-align: center;
    color: var(--ink);
}

/* The little stage: your background (a new one slides in over it), your
 * Questling, and for an effect, room on its right for the hit. */
.prize-stage {
    --ground: 22px;
    height: 180px;
    margin: 4px var(--px) 6px;
}

/* While an egg waits to be cracked: taller, more of your background round
 * it, with no words over it (app.js: hatch). */
.hatching .prize-stage {
    height: 240px;
}

.prize-stage.showing-effect .character,
.prize-stage.showing-effect .shadow {
    left: 36%;
}

.prize-stage .speech {
    max-width: calc(50% - 30px);
    font-size: 0.85rem;
    text-align: left;
}

.prize-stage.showing-effect .speech {
    left: auto;
    right: 12px;
}

.prize-stage.showing-effect .speech::after {
    right: auto;
    left: -27px;
    transform: scaleX(-1); /* pointing left, at the Questling */
}

.prize-scene {
    position: absolute;
    inset: 0;
    background: center bottom / 576px 324px no-repeat;
    image-rendering: pixelated;
}

.prize-scene.sliding {
    animation: scene-slide 0.7s 0.3s steps(7) both;
}

@keyframes scene-slide {
    from { translate: 100% 0; }
    to { translate: 0 0; }
}

/* A Questling egg on the stage (18 x 20 art, three frames: whole, cracked,
 * cracked wide; drawn 6x; ~/questlings-art/eggs/eggs.py). It rocks gently
 * from its base, faster with each crack; a tap rocks it hard (app.js:
 * crackMore). A common one is spotted blue, green, pink or red (app.js
 * picks), a rare one gold, a legendary one violet with gold spots. */
.prize-egg {
    --rock: 3deg;
    padding: 0;
    border: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: absolute;
    left: 50%;
    bottom: var(--ground);
    width: 108px;
    height: 120px;
    margin-left: -54px;
    background: url("../sprites/burrow/egg_blue_3.png") 0 0 / 300% 100% no-repeat;
    image-rendering: pixelated;
    transform-origin: 50% 100%;
}

.prize-egg:focus {
    outline: none;
}

.prize-egg[data-egg="blue"] { background-image: url("../sprites/burrow/egg_blue_3.png"); }
.prize-egg[data-egg="green"] { background-image: url("../sprites/burrow/egg_green_3.png"); }
.prize-egg[data-egg="pink"] { background-image: url("../sprites/burrow/egg_pink_3.png"); }
.prize-egg[data-egg="red"] { background-image: url("../sprites/burrow/egg_red_3.png"); }

.prize-egg.rare {
    --rock: 4deg;
    background-image: url("../sprites/burrow/egg_gold_3.png");
}

.prize-egg.rare.legendary {
    background-image: url("../sprites/burrow/egg_legendary_3.png");
}

/* Round a rare egg: white twinkles popping on and off; round a legendary
 * one, gold and white stars, and (::before) a violet glow that pulses. The
 * overlays are 26 x 28 art pixels with the egg's 18 x 20 box at (4, 4),
 * drawn 6x like the egg, so they rock with it. */
.prize-egg.rare::after,
.prize-egg.legendary::before {
    content: "";
    position: absolute;
    left: -24px;
    top: -24px;
    width: 156px;
    height: 168px;
    image-rendering: pixelated;
    pointer-events: none;
}

.prize-egg.rare::after {
    background: url("../sprites/burrow/sparkle_rare.png") 0 0 / 936px 168px no-repeat;
    animation: twinkle-6 1.1s steps(6) infinite;
}

.prize-egg.rare.legendary::after {
    background: url("../sprites/burrow/sparkle_legendary.png") 0 0 / 1248px 168px no-repeat;
    animation: twinkle-8 1.3s steps(8) infinite;
}

.prize-egg.legendary::before {
    background: url("../sprites/burrow/glow_legendary.png") 0 0 / 156px 168px no-repeat;
    animation: egg-glow 0.9s ease-in-out infinite alternate;
}

@keyframes twinkle-6 { to { background-position: -936px 0; } }
@keyframes twinkle-8 { to { background-position: -1248px 0; } }
@keyframes egg-glow {
    from { opacity: 0.35; }
    to { opacity: 1; }
}

/* The basket's deal: three eggs, two common and the gold (rare) one peeking
 * over them (static/sprites/burrow/egg_trio.png, 34 x 27 at 3x; made by
 * ~/questlings-art/eggs/eggs.py). */
.egg-icon {
    width: 102px;
    height: 81px;
    margin: 0 auto;
    background: url("../sprites/burrow/egg_trio.png") 0 0 / 100% 100% no-repeat;
    image-rendering: pixelated;
}

/* The flash as an egg hatches: bright where the egg was, filling the stage. */
.prize-flash {
    position: absolute;
    inset: 0;
    z-index: 3;
    opacity: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 62%, #ffffff 0 22%, rgb(255 255 255 / 0.92) 55%, rgb(255 255 255 / 0.8));
}

.prize-flash.rare {
    background: radial-gradient(circle at 50% 62%, #fffdf0 0 22%, rgb(255 236 170 / 0.92) 55%, rgb(255 224 140 / 0.8));
}

.prize-egg[data-crack="1"] { background-position: 50% 0; }
.prize-egg[data-crack="2"] { background-position: 100% 0; }

.prize-egg.wobble {
    animation: egg-rock 1.6s ease-in-out infinite;
}

.prize-egg.wobble[data-crack="1"] { --rock: 6deg; animation-duration: 1.1s; }
.prize-egg.wobble[data-crack="2"] { --rock: 9deg; animation-duration: 0.7s; }

@keyframes egg-rock {
    0%, 100% { rotate: calc(var(--rock) * -1); }
    50% { rotate: var(--rock); }
}

/* A gold-chest Questling you haven't found yet: a dark shape. */
.chip.locked {
    cursor: default;
    opacity: 0.85;
}

.chip.locked .creature-pic {
    filter: brightness(0) opacity(0.45);
}

/* --- Rarity tiers ------------------------------------------------------------
 * Every Questling (chip) and effect (card) on the Look tab is a card for
 * its rarity: its picture on a panel (.tier-panel: pale blue for common, gold
 * diamonds with sparkles for rare, a twinkling night sky for legendary);
 * a rare one in a thick two-tone gold frame with its name in gold
 * (.rare-name); a legendary one in a frame that shimmers through purple,
 * cyan and pink, its name in the logo's bouncing letters (.legend-name).
 * The frames sit just inside the ink border, so they take no more room. */
.chip.chip-swatch,
.shop-card {
    position: relative;
}

.chip.chip-swatch {
    padding: 6px; /* room for a frame; two still fit side by side on a phone */
}

.chip.tier-rare {
    box-shadow: inset 0 0 0 var(--px) var(--gold-dark), inset 0 0 0 calc(var(--px) * 2) var(--gold),
        inset 0 -4px 0 calc(var(--px) * 2) var(--parchment-3), var(--notch);
}

.chip.tier-rare.active {
    box-shadow: inset 0 0 0 var(--px) var(--gold-dark), inset 0 0 0 calc(var(--px) * 2) var(--gold-light),
        inset 0 -4px 0 calc(var(--px) * 2) var(--gold-dark), var(--notch);
}

.shop-card.tier-rare {
    box-shadow: inset 0 0 0 var(--px) var(--gold-dark), inset 0 0 0 calc(var(--px) * 2) var(--gold), var(--notch);
}

.chip.tier-legendary {
    animation: legend-ring-chip 3s linear infinite;
}

.chip.tier-legendary.active {
    animation-name: legend-ring-chip-on;
}

.shop-card.tier-legendary {
    animation: legend-ring-card 3s linear infinite;
}

@keyframes legend-ring-card {
    0%, 100% { box-shadow: inset 0 0 0 calc(var(--px) * 2) #b46cff, var(--notch); }
    33% { box-shadow: inset 0 0 0 calc(var(--px) * 2) #29d6ff, var(--notch); }
    66% { box-shadow: inset 0 0 0 calc(var(--px) * 2) #ff7ad9, var(--notch); }
}

@keyframes legend-ring-chip {
    0%, 100% { box-shadow: inset 0 0 0 calc(var(--px) * 2) #b46cff, inset 0 -4px 0 calc(var(--px) * 2) var(--parchment-3), var(--notch); }
    33% { box-shadow: inset 0 0 0 calc(var(--px) * 2) #29d6ff, inset 0 -4px 0 calc(var(--px) * 2) var(--parchment-3), var(--notch); }
    66% { box-shadow: inset 0 0 0 calc(var(--px) * 2) #ff7ad9, inset 0 -4px 0 calc(var(--px) * 2) var(--parchment-3), var(--notch); }
}

@keyframes legend-ring-chip-on {
    0%, 100% { box-shadow: inset 0 0 0 calc(var(--px) * 2) #b46cff, inset 0 -4px 0 calc(var(--px) * 2) var(--gold-dark), var(--notch); }
    33% { box-shadow: inset 0 0 0 calc(var(--px) * 2) #29d6ff, inset 0 -4px 0 calc(var(--px) * 2) var(--gold-dark), var(--notch); }
    66% { box-shadow: inset 0 0 0 calc(var(--px) * 2) #ff7ad9, inset 0 -4px 0 calc(var(--px) * 2) var(--gold-dark), var(--notch); }
}

/* The panels (static/sprites/ui/panel_*.png and sky.png, 24 x 24 tiles
 * at 3x; ~/questlings-art/ui/source/panels.py). The night sky has a few
 * bigger stars fading in and out behind the picture. */
.tier-panel {
    position: relative;
    background-repeat: repeat;
    background-size: 72px 72px;
    image-rendering: pixelated;
    border-radius: 6px;
}

.tier-panel-common { background-image: url("../sprites/ui/panel_common.png"); }
.tier-panel-rare { background-image: url("../sprites/ui/panel_rare.png"); }
/* the night sky, with a soft glow along the bottom so a Questling's dark feet
 * line shows against it */
.tier-panel-legendary {
    background: url("../sprites/ui/sky_horizon.png") left bottom / 72px 24px repeat-x,
        url("../sprites/ui/sky.png") 0 0 / 72px 72px repeat;
}

.tier-panel-legendary::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url("../sprites/ui/sky_twinkle.png") 0 0 / 72px 72px repeat;
    image-rendering: pixelated;
    animation: sky-twinkle 1.8s ease-in-out infinite alternate;
    pointer-events: none;
}

.tier-panel > * {
    position: relative; /* in front of the twinkles */
}

.shop-pic.tier-panel-legendary::after {
    color: #e9e4ff; /* "Tap to play", light on the dark sky */
}

@keyframes sky-twinkle {
    from { opacity: 0.15; }
    to { opacity: 1; }
}

/* A personality held while your Questling has its own (app.js:
 * updateCreate): faded, with a lock in its corner. */
.chip.held {
    position: relative;
    opacity: 0.5;
}

.chip.held::after {
    content: "🔒";
    position: absolute;
    top: 6px;
    right: 10px;
    font-size: 0.85rem;
}

/* A rare name: gold, outlined in ink. */
.rare-name {
    color: var(--gold);
    -webkit-text-stroke: 0.12em var(--line);
    paint-order: stroke fill;
}

.chip.active .rare-name {
    color: #fff6dc; /* on the chosen chip's gold */
}

/* A legendary name: the logo's letters, smaller, bobbing in a wave. */
.legend-name {
    white-space: nowrap;
}

/* Each letter of a legendary name stands alone, with an ink stroke and a
 * drop like the logo's, in its Questling's own colours and movement
 * (app.js: legendName). */
.legend-name b {
    display: inline-block;
    font-weight: 700;
    -webkit-text-stroke: 0.1em var(--legend-ink);
    paint-order: stroke fill;
    text-shadow: 0 0.07em 0 var(--legend-ink);
}

/* Voltrix: electric cyan, and every few seconds a spark runs along the
 * word: each letter in turn flashes lightning yellow and jolts. */
.legend-voltix {
    --legend-ink: #0b1a3a;
}

.legend-voltix b {
    color: #8ff0ff;
    animation: legend-spark 2.8s steps(1) infinite;
}

@keyframes legend-spark {
    0%, 6%, 100% { color: #8ff0ff; translate: 0 0; }
    1.5% { color: #fff36b; translate: 0.03em -0.05em; }
    3% { color: #ffffff; translate: -0.03em 0.02em; }
    4.5% { color: #c9fbff; translate: 0 0; }
}

/* Ignis: ember orange, each letter flickering up like a flame, hotter as
 * it rises. */
.legend-ignis {
    --legend-ink: #2a0d06;
}

.legend-ignis b {
    color: #ff8a1f;
    animation: legend-ember 1.4s ease-in-out infinite;
}

@keyframes legend-ember {
    0%, 100% { color: #ff8a1f; translate: 0 0; }
    45% { color: #ffd34d; translate: 0 -0.1em; }
    60% { color: #ffe9a0; translate: 0 -0.08em; }
}

/* Lunara: pale silver, and every few seconds a slow gold glint sweeps
 * across the word, letter by letter: moonlight passing over it. */
.legend-lunara {
    --legend-ink: #1d1440;
}

.legend-lunara b {
    color: #e6e9ff;
    animation: legend-shimmer 4s ease-in-out infinite;
}

@keyframes legend-shimmer {
    0%, 14%, 100% { color: #e6e9ff; }
    5% { color: #ffe27a; }
    8% { color: #fff8d8; }
}

/* A legendary nobody has found yet ("???"): quiet, pale lilac. */
.legend-unknown {
    --legend-ink: #2a1a55;
}

.legend-unknown b {
    color: #e3d6ff;
}

/* The hatch banner pops up once the egg is open. */
.prize-banner.popped {
    animation: banner-pop 0.35s steps(4) both;
}

@keyframes banner-pop {
    from { scale: 0.4; opacity: 0; }
    to { scale: 1; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .legend-name b,
    .prize-banner.popped {
        animation: none;
    }
}

/* A theme's picture: a tiny page in its own colours (app.js: themePicture),
 * its top bar, the board, a note and a button. "Match my phone" shows two. */
.theme-pic {
    display: flex;
    gap: var(--px);
    overflow: hidden;
    background: var(--line);
}

/* The usual button green, for previews of themes that don't set their own
 * (so they don't borrow the theme in use); :where keeps this weaker than a
 * theme's own colours. */
:where(.theme-mini) {
    --leaf: #62a854;
    --leaf-dark: #3f7535;
}

.theme-mini {
    position: relative;
    flex: 1;
    background: linear-gradient(var(--bg-top), var(--bg));
}

.theme-mini > span {
    position: absolute;
    box-shadow: 0 0 0 2px var(--line);
    border-radius: 3px;
}

.tm-bar { left: 8%; right: 8%; top: 9%; height: 14%; background: var(--parchment); }
.tm-board { left: 8%; right: 8%; top: 33%; bottom: 10%; background: var(--board); }
.tm-note { left: 15%; top: 44%; width: 40%; height: 26%; background: var(--parchment); }
.tm-button { right: 15%; top: 44%; width: 22%; height: 16%; background: var(--leaf); }

/* A theme won from a chest, sliding onto the prize stage. */
.prize-scene .theme-pic {
    position: absolute;
    inset: 0;
    height: auto;
    margin: 0;
}

/* A hit effect locked while your Questling has its own: faded, a lock for
 * its button. */
.shop-card.locked {
    opacity: 0.6;
}


.banner-word {
    white-space: nowrap;
}

.achievement-pal {
    --scale: 3;
    margin: 4px auto;
}

.achievement-pal[hidden] {
    display: none;
}

/* "Keep it for later": small, under the big button. */
.btn-link {
    justify-self: center;
    padding: 6px 10px;
    border: 0;
    background: none;
    font: 600 0.95rem var(--font-body);
    color: var(--ink-soft);
    text-decoration: underline;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    .prize-chest.dropping,
    .prize-banner > b,
    .banner-word > b,
    .prize-scene.sliding {
        animation: none;
    }
}

#chest-prize {
    display: grid;
    gap: 8px;
}

#chest-prize .title {
    margin: 0;
}

/* --- Soft corners --------------------------------------------------------------
 * Everything with the ink border gets rounded corners. (The burrow has no
 * border: it runs to the edges of the screen.) Last in the file so it wins. */
.panel,
.btn,
.input,
.fold,
.chip,
.coins,
.carry,
.note,
.shop-card,
.shop-pic,
.tabs button[aria-current="page"],
.overlay-box {
    border-radius: var(--radius);
}

.icon-btn,
.quest-check {
    border-radius: 8px;
}

/* --- Settings ------------------------------------------------------------------ */
.settings .setting-name {
    display: block;
    margin: 14px 0 6px;
    font: 600 1rem var(--font-head);
}

.settings .label + .setting-name {
    margin-top: 2px;
}

.settings .setting-hint,
.setting-hint {
    margin: 6px 0 0;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.setting-hint.error {
    color: var(--berry);
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider-row input {
    flex: 1;
    min-width: 0;
    accent-color: var(--gold-dark);
}

.slider-a {
    font: 700 0.9rem var(--font-head);
}

.slider-a.big {
    font-size: 1.5rem;
}

.account-form {
    display: grid;
    gap: 6px;
}

.account-form label {
    font-weight: 700;
    font-size: 0.95rem;
}

#logout {
    margin-bottom: 12px;
}

.fold.danger summary {
    color: var(--berry);
}

.btn-danger {
    background: var(--berry);
    box-shadow: inset 0 -5px 0 0 var(--berry-dark), var(--notch);
}

.btn-danger:active {
    box-shadow: inset 0 -2px 0 0 var(--berry-dark), var(--notch);
}

/* How rewards work: the title on top and Got it at the bottom stay put,
 * and the short sections between them scroll. */
.help-box {
    max-height: calc(100dvh - 32px);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.help-scroll {
    display: grid;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin-right: -6px;          /* room for the scroll bar */
    padding-right: 6px;
}

.help-box > .btn {
    flex: none;
}

.help-box .title {
    margin: 0;
    text-align: center;
}

.help-box h3 {
    margin: 0 0 2px;
    font: 600 1.1rem var(--font-head);
}

.help-box p {
    margin: 0;
}

/* --- Typing without the zoom ------------------------------------------------------
 * iPhone Safari zooms in on any text box whose text is under 16 px, and
 * stays zoomed. Text boxes never go under 16 px, whatever the text size in
 * Settings; app.js (unzoom) also puts the page back if it zoomed anyway. */
.input,
.note-input,
.note-title-input,
textarea,
select {
    font-size: max(16px, 1rem);
}

/* --- Focus mode (app.js: focus) ----------------------------------------------- */
/* The Focus button, in the stage's top right corner. */
.stage-focus {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    padding: 4px 12px 6px;
    border: 0;
    border-radius: var(--radius);
    background: var(--parchment);
    box-shadow: var(--notch), 0 3px 0 var(--parchment-3);
    font: 600 0.95rem var(--font-head);
    color: var(--ink);
    cursor: pointer;
}

.stage-focus:active {
    transform: translateY(2px);
}

body.focusing .stage-focus {
    display: none;
}

/* The punching bag (app.js: dropBag): 18 x 64 art pixels, 3 frames, at the
 * stage's scale, hanging in front of your Questling, its rope running up
 * out of the top of the stage. */
.punching-bag {
    position: absolute;
    left: calc(50% + 34px);
    bottom: calc(var(--ground) + 12px);
    width: calc(18px * var(--scale));
    height: calc(64px * var(--scale));
    background: url("../sprites/ui/punching_bag.png") 0 0 / calc(54px * var(--scale)) 100% no-repeat;
    image-rendering: pixelated;
    pointer-events: none;
}

.punching-bag[data-frame="1"] { background-position: calc(-18px * var(--scale)) 0; }
.punching-bag[data-frame="2"] { background-position: calc(-36px * var(--scale)) 0; }

/* While focusing: only the stage and the focus panel, no board, no tabs. */
body.focusing .quests,
body.focusing #tabs {
    display: none !important;
}

.focus-panel {
    display: grid;
    justify-items: center;
    gap: 2px;
    text-align: center;
}

.focus-label {
    margin: 0;
    font: 700 0.8rem var(--font-body);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

/* The session's quests (and the end sheet's list): a checkbox each, to
 * tick off as you go. */
.focus-list {
    display: grid;
    gap: 6px;
    width: 100%;
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    text-align: left;
}

.focus-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    cursor: pointer;
}

.focus-item-text {
    font: 600 1.1rem var(--font-head);
    overflow-wrap: anywhere;
}

.focus-item.done .focus-item-text {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Write a quest, and Add. */
.focus-add {
    display: flex;
    gap: 8px;
    width: 100%;
}

.focus-add .input {
    flex: 1;
    min-width: 0;
}

.focus-add .btn {
    margin: 0;
    padding-inline: 16px;
}

.focus-time {
    margin: 6px 0 0;
    font: 700 3rem/1 var(--font-head);
    font-variant-numeric: tabular-nums;
}

.focus-hint {
    margin: 0;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.focus-panel > .btn {
    margin-top: 10px;
}

.focus-box {
    display: grid;
    gap: 10px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.focus-box .title {
    margin: 0;
}

.focus-quests {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    max-height: 40vh;
    overflow-y: auto;
}

.focus-pick {
    min-height: 40px;
    padding: 6px 12px;
    font: 600 0.95rem var(--font-body);
    overflow-wrap: anywhere;
}

.focus-end-text {
    margin: 0;
    font-weight: 700;
}

.focus-end-coins {
    margin: 0;
    font: 600 1.4rem var(--font-head);
    color: var(--gold-dark);
}
