/**
 * Zoo Game — Interface styles.
 *
 * Tokens first, then the layers (canvases, screens), then each component. The world is
 * the subject, so the chrome sits round its edges in warm, light cards with big rounded
 * targets — the main player is a child, and every button should be easy to hit and
 * obvious about what it does.
 */

/* ==================================================================== *
 * Tokens
 * ==================================================================== */

:root {
    --card: rgba(255, 251, 241, 0.95);
    --card-2: rgba(246, 239, 222, 0.96);
    --card-line: rgba(92, 72, 40, 0.16);
    --ink: #2c2a24;
    --ink-dim: #6b6455;
    --ink-faint: #9b937f;

    --green: #2f8a52;
    --green-deep: #236b3f;
    --green-soft: #dcefd9;
    --orange: #f0952b;
    --orange-deep: #c8711a;
    --orange-soft: #fde6c8;
    --blue: #3a8fc4;
    --blue-soft: #d8ecf8;
    --red: #d9534a;
    --red-soft: #f8dcd8;
    --gold: #f4b31d;

    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 22px;
    --r-pill: 999px;

    --shadow: 0 6px 22px rgba(40, 30, 10, 0.22);
    --shadow-lg: 0 18px 50px rgba(40, 30, 10, 0.3);

    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --pop: cubic-bezier(0.34, 1.4, 0.64, 1);

    --font: 'Nunito', 'Segoe UI Rounded', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

/* `hidden` always wins over a component's own display (a grid or flex would otherwise show it). */
[hidden] { display: none !important; }

body {
    background: #2a3a2c;
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
}

button {
    font: inherit;
    color: inherit;
    border: 0;
    background: none;
    cursor: pointer;
}

button:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

kbd {
    display: inline-block;
    padding: 0 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--card-line);
    font: 600 12px/1.6 var(--font);
}

/* ==================================================================== *
 * Layers
 * ==================================================================== */

#world, #overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#world { z-index: 0; cursor: grab; touch-action: none; }
#world.is-dragging { cursor: grabbing; }
body.is-over-target #world:not(.is-dragging) { cursor: pointer; }

/* The overlay never takes the pointer: every click belongs to the zoo or a panel. */
#overlay { z-index: 1; pointer-events: none; }

.screen {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 320ms var(--ease), visibility 320ms;
}

.screen.is-active { opacity: 1; visibility: visible; }
.screen.is-active > * { pointer-events: auto; }

/* ==================================================================== *
 * Buttons
 * ==================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: var(--r-pill);
    font-weight: 800;
    font-size: 15px;
    transition: transform 120ms var(--ease), background 120ms, box-shadow 120ms;
}

.btn:active { transform: scale(0.97); }

.btn--go {
    background: var(--green);
    color: #fff;
    box-shadow: 0 4px 0 var(--green-deep);
}

.btn--go:hover { background: #359a5c; }

.btn--food {
    background: var(--orange);
    color: #fff;
    box-shadow: 0 4px 0 var(--orange-deep);
}

.btn--food:hover { background: #f6a23e; }

.btn--clean {
    background: var(--blue);
    color: #fff;
    box-shadow: 0 4px 0 #2a6f9c;
}

.btn--clean:hover { background: #4a9cd0; }

.btn--ghost {
    background: var(--card);
    color: var(--ink);
    box-shadow: var(--shadow);
}

.btn--ghost:hover { background: #fff; }

.btn--small { min-height: 34px; padding: 0 12px; font-size: 13px; }

.btn[disabled], .btn.is-busy {
    opacity: 0.55;
    cursor: default;
    transform: none;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--card);
    box-shadow: var(--shadow);
}

.icon-btn svg { width: 22px; height: 22px; fill: var(--ink); stroke: var(--ink); stroke-width: 0; }
.icon-btn svg [stroke-width] { stroke-width: 2; }
.icon-btn.is-muted svg { fill: var(--ink-faint); stroke: var(--ink-faint); }

/* ==================================================================== *
 * Title
 * ==================================================================== */

#screen-title {
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background: radial-gradient(ellipse at center, rgba(20, 30, 18, 0.1), rgba(20, 30, 18, 0.55));
    overflow-y: auto;
}

.title {
    width: min(880px, 100%);
    padding: 32px 36px 24px;
    border-radius: var(--r-lg);
    background: var(--card);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.title__eyebrow {
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--green);
}

.title__name {
    margin: 4px 0 8px;
    font-size: clamp(40px, 7vw, 64px);
    line-height: 1;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.title__name b { color: var(--green); }

.title__tagline {
    max-width: 560px;
    margin: 0 auto 22px;
    color: var(--ink-dim);
    font-size: 16px;
}

.title__hint { margin-top: 18px; color: var(--ink-faint); font-size: 13px; }

.zoo-choice {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    text-align: left;
}

.zoo-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    border-radius: var(--r-md);
    background: var(--card-2);
    border: 2px solid var(--card-line);
    transition: border-color 140ms, transform 140ms var(--ease);
}

.zoo-card:hover { border-color: var(--green); transform: translateY(-2px); }

.zoo-card__map {
    width: 100%;
    aspect-ratio: 1.6;
    border-radius: var(--r-sm);
    background: #8fb36a;
    display: block;
}

.zoo-card__name { font-size: 22px; font-weight: 900; }
.zoo-card__place { font-size: 13px; color: var(--ink-faint); font-weight: 700; }
.zoo-card__blurb { font-size: 14px; color: var(--ink-dim); flex: 1; }
.zoo-card__save { font-size: 13px; font-weight: 700; color: var(--green-deep); }
.zoo-card__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ==================================================================== *
 * Top bar
 * ==================================================================== */

.topbar {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 12px;
    pointer-events: none;
}

.topbar > * { pointer-events: auto; }

.badge {
    justify-self: start;
    display: grid;
    gap: 2px;
    padding: 10px 16px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--shadow);
}

.badge__name { font-weight: 900; font-size: 18px; }
.badge__stars { color: var(--gold); font-size: 20px; letter-spacing: 2px; line-height: 1; }
.badge__stars .is-off { color: rgba(92, 72, 40, 0.2); }
.badge__count { font-size: 13px; color: var(--ink-dim); }

.clock {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 8px 10px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--shadow);
}

.clock__arc { width: 96px; height: 34px; display: block; }
.clock__read { display: grid; }
.clock__time { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; }

.clock__meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--ink-dim);
    font-weight: 700;
}

.clock__meta i { display: inline-flex; width: 14px; height: 14px; margin-left: 4px; }
.clock__meta svg { width: 14px; height: 14px; fill: var(--orange); stroke: var(--orange); }

.controls { justify-self: end; display: flex; gap: 8px; align-items: center; }

.speeds {
    display: flex;
    gap: 2px;
    padding: 4px;
    border-radius: var(--r-pill);
    background: var(--card);
    box-shadow: var(--shadow);
}

.speed-btn {
    min-width: 40px;
    height: 36px;
    padding: 0 8px;
    border-radius: var(--r-pill);
    font-weight: 800;
    font-size: 14px;
    color: var(--ink-dim);
}

.speed-btn:hover { background: rgba(0, 0, 0, 0.05); }
.speed-btn.is-active { background: var(--green); color: #fff; }

/* ==================================================================== *
 * Toasts and the hint
 * ==================================================================== */

.toasts {
    position: absolute;
    top: 96px;
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    gap: 6px;
    justify-items: center;
    pointer-events: none !important;
}

.toast {
    padding: 8px 18px;
    border-radius: var(--r-pill);
    background: var(--card);
    box-shadow: var(--shadow);
    font-weight: 800;
    font-size: 14px;
    opacity: 0;
    transform: translateY(-6px) scale(0.96);
    transition: opacity 220ms var(--ease), transform 260ms var(--pop);
}

.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateY(-6px); }
.toast--good { color: var(--green-deep); }
.toast--warm { color: var(--orange-deep); }
.toast--cool { color: #2a6f9c; }
.toast--bad { color: var(--red); }
.toast--muted { color: var(--ink-dim); }

.hint {
    position: absolute;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    max-width: min(560px, calc(100% - 32px));
    padding: 10px 20px;
    border-radius: var(--r-pill);
    background: var(--green);
    color: #fff;
    font-weight: 800;
    text-align: center;
    box-shadow: var(--shadow);
    pointer-events: none !important;
    transition: opacity 260ms var(--ease);
}

.hint:empty { opacity: 0; }

/* ==================================================================== *
 * Next-animal task, and the unlock announcement
 * ==================================================================== */

.goal {
    position: absolute;
    top: 118px;
    left: 12px;
    width: 250px;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--shadow);
}

.goal:empty { display: none; }
.goal__art { width: 56px; height: 44px; flex: none; filter: brightness(0.35) saturate(0); }
.goal__body { display: grid; gap: 3px; min-width: 0; }
.goal__title { font-weight: 900; font-size: 14px; }
.goal__text { font-size: 12.5px; color: var(--ink-dim); font-weight: 700; }

.goal__bar {
    display: block;
    height: 8px;
    border-radius: var(--r-pill);
    background: rgba(92, 72, 40, 0.12);
    overflow: hidden;
}

.goal__fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: var(--r-pill);
    background: var(--gold);
    transition: width 400ms var(--ease);
}

.unlock {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none !important;
    opacity: 0;
    transition: opacity 260ms var(--ease);
}

.unlock.is-open { opacity: 1; }
.unlock.is-open .unlock__card { pointer-events: auto; transform: none; }

.unlock__card {
    display: grid;
    justify-items: center;
    gap: 6px;
    width: min(340px, calc(100% - 32px));
    padding: 22px 24px;
    border-radius: var(--r-lg);
    background: var(--card);
    box-shadow: var(--shadow-lg);
    border: 3px solid var(--gold);
    text-align: center;
    transform: scale(0.85);
    transition: transform 360ms var(--pop);
}

.unlock__eyebrow { font-weight: 900; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--orange-deep); }
.unlock__art { width: 168px; height: 132px; }
.unlock__name { font-size: 30px; font-weight: 900; }
.unlock__blurb { color: var(--ink-dim); font-size: 14px; margin-bottom: 6px; }

.species.is-locked { opacity: 0.85; }
.species.is-locked canvas { filter: brightness(0.35) saturate(0); }
.species.is-locked .species__why { color: var(--orange-deep); }

/* ==================================================================== *
 * Keeper card and map
 * ==================================================================== */

.keeper {
    position: absolute;
    left: 12px;
    bottom: 12px;
    width: 250px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--shadow);
}

.keeper__head { display: flex; gap: 10px; align-items: center; }
.keeper__icon { font-size: 30px; line-height: 1; }
.keeper__title { display: block; font-weight: 900; }
.keeper__status { display: block; font-size: 13px; color: var(--ink-dim); }
.keeper__line { display: block; }

.keeper__jobs {
    list-style: none;
    display: grid;
    gap: 4px;
    margin-top: 8px;
}

.keeper__jobs:empty { display: none; }

.keeper__jobs li {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    background: var(--card-2);
    font-size: 13px;
    font-weight: 700;
}

.keeper__jobs li.is-now { background: var(--green-soft); }

.map {
    position: absolute;
    left: 12px;
    bottom: calc(12px + var(--keeper-h, 92px) + 10px);
    padding: 6px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--shadow);
}

.map__canvas {
    display: block;
    width: 170px;
    height: 170px;
    border-radius: var(--r-sm);
    cursor: pointer;
}

/* ==================================================================== *
 * Enclosure panel
 * ==================================================================== */

.panel {
    position: absolute;
    top: 96px;
    right: 12px;
    bottom: 12px;
    width: 340px;
    display: flex;
    flex-direction: column;
    border-radius: var(--r-lg);
    background: var(--card);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateX(calc(100% + 24px));
    transition: transform 320ms var(--ease);
}

.panel.is-open { transform: none; }

.panel__head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--card-line);
}

.panel__title { flex: 1; }
.panel__name { font-size: 22px; font-weight: 900; line-height: 1.1; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 2px 10px;
    border-radius: var(--r-pill);
    background: var(--green-soft);
    color: var(--green-deep);
    font-size: 12px;
    font-weight: 800;
}

.chip--savanna { background: #f6ebc4; color: #8a6a12; }
.chip--forest { background: #d6ecd2; color: #2c6b33; }
.chip--rocky { background: #e7e2da; color: #6b6052; }
.chip--wetland { background: #d4ebe6; color: #22685c; }
.chip--coast { background: #d8ecf8; color: #2a6f9c; }
.chip--island { background: #dcefd9; color: #236b3f; }

.panel__close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--card-2);
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
}

.panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px 18px;
    display: grid;
    align-content: start;
    gap: 16px;
}

.panel__section h3 {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.meters { display: grid; gap: 8px; }

.meter { display: grid; grid-template-columns: 74px 1fr; gap: 8px; align-items: center; }
.meter__label { font-weight: 800; font-size: 13px; }

.meter__bar {
    display: block;
    height: 12px;
    border-radius: var(--r-pill);
    background: rgba(92, 72, 40, 0.12);
    overflow: hidden;
}

.meter__fill {
    display: block;
    height: 100%;
    width: 50%;
    border-radius: var(--r-pill);
    background: var(--green);
    transition: width 400ms var(--ease), background 400ms;
}

.meter__fill.is-mid { background: var(--orange); }
.meter__fill.is-low { background: var(--red); }

.jobs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 4px; }
.jobs .btn { width: 100%; }

.btn--fun {
    background: #9a5bc8;
    color: #fff;
    box-shadow: 0 4px 0 #74409c;
}

.btn--fun:hover { background: #a86bd4; }

/* The enclosure's toy chooser (named apart from the shop's toy shelf, `.toys`). */
.play-pick, .improve { display: grid; gap: 6px; margin-top: 10px; }
.improve { margin-top: 0; }
.play-pick__hint { font-size: 12.5px; font-weight: 800; color: #74409c; }

.play-option, .improve__item {
    display: grid;
    grid-template-columns: 32px 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 8px;
    padding: 6px 10px;
    border-radius: var(--r-sm);
    background: var(--card-2);
    border: 2px solid transparent;
    text-align: left;
}

.play-option:hover, .improve__item:not(:disabled):hover { border-color: #9a5bc8; }
.play-option__icon, .improve__icon { grid-row: span 2; font-size: 22px; text-align: center; }
.play-option__name, .improve__name { font-weight: 900; font-size: 14px; }
.play-option__blurb, .improve__blurb { font-size: 12px; color: var(--ink-dim); }
.improve__item.is-done { opacity: 0.7; cursor: default; }
.improve__item.is-done .improve__blurb { color: var(--green-deep); font-weight: 800; }

.letters {
    position: absolute;
    top: 224px;
    left: 12px;
    width: 250px;
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--shadow);
}

.letters:empty { display: none; }
.letters__head { font-weight: 900; font-size: 14px; }
.letter { display: grid; gap: 6px; padding: 8px; border-radius: var(--r-sm); background: var(--orange-soft); }
.letter__text { display: grid; font-size: 13px; }
.letter__text span { color: var(--ink-dim); font-style: italic; }

.postcard {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    width: min(620px, calc(100% - 32px));
    border-radius: var(--r-md);
    background: #fffaf0;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 8px solid #fffaf0;
    transform: scale(0.85) rotate(-2deg);
    transition: transform 360ms var(--pop);
}

.unlock.is-open .postcard { pointer-events: auto; transform: rotate(-1deg); }

.postcard__scene {
    position: relative;
    min-height: 220px;
    border-radius: 6px;
    display: grid;
    place-items: end center;
    background: linear-gradient(#9fd2f0 0%, #cfe9f7 52%, #8cc063 52%, #5f9a42 100%);
}

.postcard__scene--forest, .postcard__scene--island {
    background: linear-gradient(#a7d8c0 0%, #d6efe0 45%, #4f8a4a 45%, #2f6b36 100%);
}

.postcard__scene--savanna, .postcard__scene--rocky {
    background: linear-gradient(#f7c98a 0%, #fbe3b8 50%, #d9c26e 50%, #b89c4a 100%);
}

.postcard__scene--coast, .postcard__scene--wetland {
    background: linear-gradient(#9fd2f0 0%, #d6eef9 50%, #4a9ccc 50%, #e3d3a4 80%);
}

.postcard__art { width: 220px; height: 172px; margin-bottom: 8px; }
.postcard__stamp { position: absolute; top: 8px; right: 10px; font-size: 26px; transform: rotate(8deg); }

.postcard__note {
    display: grid;
    align-content: center;
    gap: 10px;
    padding: 14px 16px;
    font-family: 'Segoe Print', 'Comic Sans MS', var(--font);
    background: repeating-linear-gradient(#fffaf0 0 26px, #e9dcc0 26px 27px);
}

.postcard__from { font-weight: 900; font-size: 18px; color: var(--green-deep); }
.postcard__text { font-size: 14px; line-height: 1.6; }

.btn--extras { position: relative; }

.btn--extras.has-badge::after {
    content: attr(data-badge);
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: var(--r-pill);
    background: var(--red);
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}

.extras {
    position: absolute;
    top: 96px;
    right: 12px;
    bottom: 12px;
    width: 360px;
    display: flex;
    flex-direction: column;
    border-radius: var(--r-lg);
    background: var(--card);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateX(calc(100% + 24px));
    transition: transform 320ms var(--ease);
    z-index: 3;
}

.extras.is-open { transform: none; }
.extras__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px; }
.extras__head h2 { font-size: 22px; font-weight: 900; }
.extras__intro { padding: 0 16px 10px; font-size: 13px; color: var(--ink-dim); }
.extras__list { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 8px; padding: 4px 14px 16px; }

.extra {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--r-md);
    background: var(--card-2);
    border: 2px solid transparent;
}

.extra.is-new { border-color: var(--gold); }
.extra.is-locked .extra__icon { filter: grayscale(1); opacity: 0.55; }
.extra__icon { font-size: 28px; text-align: center; }
.extra__body { display: grid; gap: 2px; min-width: 0; }
.extra__name { font-weight: 900; font-size: 15px; }
.extra__blurb { font-size: 12px; color: var(--ink-dim); }
.extra__goal { display: grid; gap: 4px; font-size: 12px; font-weight: 800; color: var(--orange-deep); }
.extra:not(.is-locked) .extra__goal { color: var(--green-deep); }

.improve__note { font-size: 12.5px; color: var(--ink-dim); font-weight: 700; }
.unlock__icon { font-size: 72px; line-height: 1.1; }
.hint.is-mode { background: var(--orange); }

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    font-weight: 800;
    font-size: 14px;
}

.toggle__switch {
    position: relative;
    width: 44px;
    height: 26px;
    border-radius: var(--r-pill);
    background: rgba(92, 72, 40, 0.2);
    transition: background 160ms;
}

.toggle__switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 160ms var(--ease);
}

.toggle.is-on .toggle__switch { background: var(--green); }
.toggle.is-on .toggle__switch::after { transform: translateX(18px); }

.resident__sexes { font-size: 12px; font-weight: 800; color: var(--ink-dim); }

.panel__note {
    padding: 10px 12px;
    border-radius: var(--r-sm);
    background: var(--orange-soft);
    color: var(--orange-deep);
    font-weight: 700;
    font-size: 14px;
}

.panel__note--empty { background: var(--green-soft); color: var(--green-deep); }

.residents { display: grid; gap: 6px; }

.resident {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    background: var(--card-2);
}

.resident canvas { width: 56px; height: 44px; display: block; }
.resident__text { flex: 1; min-width: 0; }
.resident__name { font-weight: 900; }
.resident__sub { font-size: 12px; color: var(--ink-dim); }

.resident__remove {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(92, 72, 40, 0.08);
    font-weight: 900;
    font-size: 18px;
}

.resident__remove:hover { background: var(--red-soft); color: var(--red); }

.catalogue {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.species {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 6px 4px 8px;
    border-radius: var(--r-sm);
    background: var(--card-2);
    border: 2px solid transparent;
    transition: border-color 120ms, transform 120ms var(--ease);
}

.species canvas { width: 84px; height: 66px; display: block; }
.species__name { font-weight: 900; font-size: 13px; }
.species__food { font-size: 12px; color: var(--ink-dim); }

.species.is-ok:hover { border-color: var(--green); transform: translateY(-2px); }

.species.is-ok::after {
    content: '+';
    position: absolute;
    top: 4px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    font-weight: 900;
    line-height: 22px;
    text-align: center;
}

.species.is-no { opacity: 0.5; cursor: default; }
.species.is-no canvas { filter: grayscale(0.9); }

.species__why {
    font-size: 11px;
    line-height: 1.25;
    color: var(--red);
    font-weight: 700;
    text-align: center;
}

.catalogue__toggle {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 800;
    color: var(--green-deep);
    text-decoration: underline;
}

/* ==================================================================== *
 * Animal card
 * ==================================================================== */

.animal {
    position: absolute;
    top: 96px;
    right: calc(12px + 340px + 12px);
    width: 250px;
    padding: 14px 16px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 200ms var(--ease), transform 240ms var(--pop), visibility 200ms;
}

.animal.is-open { opacity: 1; visibility: visible; transform: none; }
.animal__name { font-size: 20px; font-weight: 900; }
.animal__kind { color: var(--ink-dim); font-weight: 700; font-size: 13px; }
.animal__mood { margin: 8px 0; font-weight: 800; }
.animal__need { color: var(--orange-deep); font-size: 13px; font-weight: 700; }
.animal__actions { display: flex; gap: 8px; margin-top: 10px; }

/* ==================================================================== *
 * Graphics device lost
 * ==================================================================== */

.context-lost {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 50;
    transform: translate(-50%, -50%);
    display: grid;
    gap: 12px;
    justify-items: center;
    padding: 22px 28px;
    border-radius: var(--r-lg);
    background: var(--card);
    box-shadow: var(--shadow-lg);
    font-weight: 700;
}

/* ==================================================================== *
 * Smaller screens
 * ==================================================================== */

@media (max-width: 1100px) {
    .animal { right: 12px; top: auto; bottom: 12px; }
    .panel.is-open ~ .animal.is-open { bottom: auto; top: 96px; right: calc(12px + 300px + 12px); }
    .panel { width: 300px; }
    .catalogue { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
    .topbar { grid-template-columns: 1fr auto; }
    .clock { display: none; }
    .map { display: none; }
    .keeper { width: auto; right: 12px; }
    .panel { top: auto; left: 12px; right: 12px; width: auto; height: 62%; }
    .panel.is-open ~ .animal.is-open { top: 96px; right: 12px; }
    .badge__count { display: none; }
}

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

/* ================================================================== */
/* Buildings: the drawer that opens when a building is tapped          */
/* ================================================================== */

.building-panel { width: 380px; }
.building__icon { font-size: 34px; line-height: 1; }
.building__blurb { padding: 10px 16px 0; font-size: 13px; color: var(--ink-dim); font-weight: 700; }
.building__lead { font-weight: 900; font-size: 16px; margin-bottom: 6px; }
.building__note { font-size: 12.5px; color: var(--ink-dim); margin-top: 6px; }
.goal__bar.is-low .goal__fill { background: var(--red); }

/* Toy shop */
.toys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.toy {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 8px 4px 6px;
    border-radius: var(--r-md);
    background: linear-gradient(#fff8e8, #f3e3c0);
    box-shadow: inset 0 -6px 0 rgba(160, 110, 50, 0.25);
}
.toy__art { width: 84px; height: 66px; object-fit: contain; }
.toy__emoji { display: grid; place-items: center; width: 84px; height: 66px; font-size: 44px; }
.toy__name { font-size: 12px; font-weight: 900; text-align: center; }
.toy.is-missing .toy__art,
.toy.is-missing .toy__emoji { filter: brightness(0); opacity: 0.18; }
.toy.is-missing .toy__name { color: var(--ink-faint); }
.toy__mini {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 1px 6px;
    border-radius: var(--r-pill);
    background: var(--gold);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
}

/* Diary */
.tabs { display: flex; gap: 6px; }
.tab {
    flex: 1;
    min-height: 36px;
    border-radius: var(--r-pill);
    background: var(--card-2);
    font-weight: 900;
    font-size: 13px;
}
.tab.is-active { background: var(--green); color: #fff; }
.diary { display: grid; gap: 6px; list-style: none; }
.diary__entry { display: grid; grid-template-columns: 26px 1fr; gap: 6px; font-size: 13.5px; }
.diary__icon { font-size: 18px; text-align: center; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
    display: grid;
    gap: 2px;
    padding: 8px;
    border-radius: var(--r-sm);
    background: #fffdf6;
    box-shadow: 0 3px 10px rgba(40, 30, 10, 0.18);
    transform: rotate(-1.2deg);
}
.card:nth-child(even) { transform: rotate(1.4deg); }
.card__art { width: 100%; height: auto; border-radius: 6px; background: linear-gradient(#cfe6f5, #e9f1d6); }
.card__from { font-size: 12.5px; }
.card__text { font-size: 11.5px; color: var(--ink-dim); }
.card__day { font-size: 11px; color: var(--ink-faint); font-weight: 800; }

/* Café */
.cafe__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cafe__stat {
    display: grid;
    justify-items: center;
    padding: 10px;
    border-radius: var(--r-md);
    background: var(--card-2);
    font-size: 12.5px;
    font-weight: 800;
    color: var(--ink-dim);
}
.cafe__stat b { font-size: 26px; color: var(--ink); line-height: 1.1; }
.cafe__special {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    background: #2f3b33;
    color: #fff;
    font-weight: 900;
    font-size: 20px;
}
.cafe__special-icon { font-size: 38px; }
.menu { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.menu__item {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 8px 2px;
    border-radius: var(--r-sm);
    background: var(--card-2);
    border: 2px solid transparent;
}
.menu__item.is-active { border-color: var(--green); background: var(--green-soft); }
.menu__icon { font-size: 26px; }
.menu__label { font-size: 11px; font-weight: 800; }

/* Indoor houses and the incubator */
.tanks, .eggs { display: grid; gap: 10px; }
.tank, .egg {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: var(--r-md);
    background: var(--card-2);
    border: 2px solid transparent;
}
.tank.is-sad, .egg.is-sad { border-color: var(--orange); }
.egg.is-empty { grid-template-columns: 92px 1fr; opacity: 0.7; }
.tank__glass, .egg__shell {
    position: relative;
    display: grid;
    place-items: center;
    height: 80px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(200, 235, 245, 0.9), rgba(120, 180, 130, 0.9));
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6), inset 0 -14px 0 rgba(120, 90, 50, 0.35);
    overflow: hidden;
}
.tank__glass--warm { background: linear-gradient(180deg, rgba(255, 228, 170, 0.95), rgba(214, 170, 110, 0.95)); }
.tank__glass--water { background: linear-gradient(180deg, rgba(160, 215, 245, 0.95), rgba(60, 140, 200, 0.95)); }
.tank__glass--flowers { background: linear-gradient(180deg, rgba(250, 220, 240, 0.95), rgba(150, 200, 120, 0.95)); }
.egg__shell { background: radial-gradient(circle at 50% 70%, #fff3cf, #f2c879); }
.tank__creature, .egg__emoji { font-size: 44px; animation: bob 2.6s ease-in-out infinite; }
.tank.is-empty .tank__creature, .egg.is-empty .egg__emoji { color: var(--ink-faint); animation: none; }
.tank.is-locked { opacity: 0.75; }
.tank.is-locked .tank__glass { filter: grayscale(0.85); }
.tank.is-locked .tank__creature { font-size: 34px; }
.egg__hint { position: absolute; right: 6px; bottom: 4px; font-size: 18px; opacity: 0.8; }
.tank__young { position: absolute; left: 6px; bottom: 4px; font-size: 18px; letter-spacing: -4px; }
.egg.is-wobbly .egg__emoji { animation: wobble 0.6s ease-in-out infinite; }
.tank__body { display: grid; gap: 4px; min-width: 0; }
.tank__name { font-size: 14.5px; }
.tank__mood { font-size: 12.5px; color: var(--ink-dim); font-weight: 700; }
.tank__meters { display: grid; gap: 4px; }
.tank__meter { display: grid; grid-template-columns: 104px 1fr; gap: 6px; align-items: center; font-size: 12px; font-weight: 800; }
.tank__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes wobble { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

/* Signposts */
.guide {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: var(--r-md);
    background: var(--card-2);
}
.guide__pics { display: flex; min-width: 48px; }
.guide__art { width: 48px; height: 38px; margin-right: -14px; }
.guide__empty { font-size: 28px; }
.guide__text { display: grid; gap: 1px; min-width: 0; font-size: 12.5px; color: var(--ink-dim); }
.guide__text b { color: var(--ink); font-size: 14px; }

@media (max-width: 760px) {
    .building-panel { width: auto; left: 12px; }
}

/* Extras: only the one being worked towards shows its goal; the rest wait their turn. */
.extra.is-waiting { opacity: 0.55; }
.extra.is-waiting .extra__goal { color: var(--ink-faint); }
.extra.is-locked:not(.is-waiting) { border-color: var(--orange-soft); }

/* Ticket office: the visitor book */
.cafe__stats--three { grid-template-columns: repeat(3, 1fr); }
.tickets__day { font-size: 12.5px; font-weight: 800; color: var(--ink-dim); }
.tickets__score { display: grid; grid-template-columns: 54px 1fr; gap: 10px; align-items: center; }
.tickets__face { font-size: 46px; line-height: 1; text-align: center; }
.tickets__scorebody { display: grid; gap: 6px; }
.tickets__number { font-size: 15px; }
.tickets__bar { height: 12px; }
.tickets__bar .goal__fill { background: var(--green); }
.tickets__parts { margin-top: 10px; }
.tickets__parts .tank__meter { grid-template-columns: 140px 1fr; }
.tickets__parts .goal__fill { background: var(--green); }
.tickets__tip {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    background: var(--orange-soft);
    color: var(--orange-deep);
    font-size: 13px;
    font-weight: 800;
}
.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 4px; }
.chart__col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.chart__bar { width: 100%; min-height: 3px; border-radius: 6px 6px 2px 2px; background: var(--blue); }
.chart__col.is-today .chart__bar { background: var(--green); }
.chart__value { font-size: 11px; font-weight: 900; }
.chart__label { font-size: 11px; font-weight: 800; color: var(--ink-dim); }
.review { display: grid; gap: 2px; padding: 8px 10px; margin-bottom: 6px; border-radius: var(--r-md); background: var(--card-2); }
.review__stars { color: var(--gold); font-size: 15px; letter-spacing: 1px; }
.review__text { font-size: 13.5px; }
.review__who { font-size: 11.5px; color: var(--ink-faint); font-weight: 800; }

/* ==================================================================== *
 * Build your own zoo
 * ==================================================================== */

.title { max-height: calc(100vh - 32px); overflow-y: auto; }
.zoo-card--build {
    align-items: center;
    justify-content: center;
    text-align: center;
    border-style: dashed;
    border-color: var(--green);
    background: var(--green-soft);
}
.zoo-card__plus { font-size: 48px; line-height: 1; color: var(--green); font-weight: 900; }
.zoo-card--build .zoo-card__actions { justify-content: center; }
.zoo-card--custom { border-color: rgba(47, 138, 82, 0.4); }

.screen--builder { background: #2f4632; }
.screen--builder.is-active { pointer-events: auto; }

.builder-setup {
    position: absolute;
    inset: 0;
    margin: auto;
    width: min(720px, calc(100% - 32px));
    height: fit-content;
    max-height: calc(100% - 32px);
    overflow-y: auto;
    padding: 26px 30px;
    border-radius: var(--r-lg);
    background: var(--card);
    box-shadow: var(--shadow-lg);
    display: grid;
    gap: 16px;
}
.builder-setup__title { font-size: 30px; font-weight: 900; }
.builder-setup__lead { color: var(--ink-dim); margin-top: -10px; }
.builder-setup__actions { display: flex; justify-content: space-between; gap: 10px; }
.builder-field { display: grid; gap: 8px; }
.builder-field__label { font-size: 12px; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.builder-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    border: 2px solid var(--card-line);
    background: #fff;
    font: inherit;
    font-size: 17px;
    font-weight: 800;
    user-select: text;
    -webkit-user-select: text;
}
.builder-input--small { font-size: 14px; padding: 7px 10px; }
.builder-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.builder-option {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 4px;
    min-height: 84px;
    padding: 8px;
    border-radius: var(--r-md);
    background: var(--card-2);
    border: 3px solid transparent;
    font-weight: 900;
}
.builder-option.is-on { border-color: var(--green); background: var(--green-soft); }
.builder-option__icon { font-size: 28px; line-height: 1; }
.builder-option__label { font-size: 13px; }

.builder {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: 1fr 330px;
    grid-template-rows: auto 1fr;
}
.builder__top {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    background: var(--card);
    box-shadow: var(--shadow);
    z-index: 1;
}
.builder__title { display: grid; flex: 1; min-width: 0; }
.builder__title b { font-size: 19px; }
.builder__title span { font-size: 12.5px; color: var(--ink-dim); font-weight: 700; }
.builder__status { font-weight: 900; font-size: 13.5px; color: var(--orange-deep); }
.builder__status.is-ok { color: var(--green-deep); }
.builder__stage { position: relative; min-height: 0; overflow: hidden; }
.builder__canvas { position: absolute; inset: 0; touch-action: none; cursor: grab; }
.builder__side {
    min-height: 0;
    overflow-y: auto;
    background: var(--card);
    padding: 12px 14px 20px;
    display: grid;
    align-content: start;
    gap: 14px;
}
.builder__side h3 { font-size: 12px; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin: 6px 0; }
.builder-stamps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.builder-stamp {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: var(--r-sm);
    background: var(--card-2);
    border: 2px solid transparent;
}
.builder-stamp:hover { border-color: var(--green); }
.builder-stamp__icon { font-size: 24px; line-height: 44px; height: 44px; }
.builder-stamp__label { font-size: 10.5px; font-weight: 800; text-align: center; line-height: 1.15; }
.builder__inspector { display: grid; gap: 8px; padding: 10px; border-radius: var(--r-md); background: var(--card-2); }
.builder__hint { font-size: 13px; color: var(--ink-dim); }
.builder-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.builder-chip {
    padding: 5px 10px;
    border-radius: var(--r-pill);
    background: #fff;
    border: 2px solid var(--chip);
    font-size: 12.5px;
    font-weight: 800;
}
.builder-chip.is-on { background: var(--chip); }
.builder-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.builder__problems { display: grid; gap: 6px; }
.builder__problems:empty { display: none; }
.builder-problem {
    text-align: left;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    background: #fbe3e1;
    color: #8f2f28;
    font-size: 13px;
    font-weight: 800;
}

@media (max-width: 760px) {
    .builder { grid-template-columns: 1fr; grid-template-rows: auto 1fr 42%; }
    .builder__top { flex-wrap: wrap; }
}
