/* =======================================================================
 * Farm game CSS (v2.0.2 — camera-follow viewport)
 *
 * Layout architecture:
 *   .mg-farm-root
 *     → header (currency / lifetime)
 *     → .mg-farm-viewport (12×8 cells × 96 = 1152×768 native, overflow hidden,
 *                          fit-to-width scaled on mobile via JS transform)
 *         → .mg-farm-scene (20×12 cells × 96 = 1920×1152 native, BIGGER than
 *                           viewport — translated by JS to camera-follow player)
 *             → .mg-farm-scene-bg     (full scene grass background, repeating)
 *             → .mg-farm-scene-chrome (positioned: houses, trees, water)
 *             → .mg-farm-scene-npc    (positioned: shop, mail markers)
 *             → .mg-farm-plot         (5×5 plot grid at scene cells (8,5)..(12,9))
 *             → .mg-farm-player       (animated player sprite, scene-absolute)
 *     → .mg-farm-main (sidebar with action panel, shop btns, inventory)
 *     → modal / toasts / footer
 *
 * Sprite scaling philosophy:
 *   Native cell = 96 display px. Cup Nooble sprites come in two source
 *   sizes:
 *     - 16px tiles (grass, tilled-dirt, decorations) → 16 × 6 scale = 96.
 *       Wait — 6× would look chunky. We use 16 × 3 = 48 was prior; for
 *       this redesign keep cell at 96 by doubling the 48 manifest values.
 *       Actually: use SPRITE_SCALE = 6 (16→96) so each native 16px tile
 *       fills exactly one 96px cell. Verified crisp at integer scale.
 *     - 48px character / tree frames → 48 × 2 = 96 display.
 *
 *   image-rendering: pixelated keeps edges crisp at integer scale.
 *
 * @since 2.0.2
 * ===================================================================== */

.mg-farm-root {
    --cell: 96px;
    --plot-cols: 6;
    --plot-rows: 4;
    --scene-cols: 20;
    --scene-rows: 16;
    --viewport-cols: 9;
    --viewport-rows: 6;
    /* v2.0.38 — wood palette.
     *
     * The farm root now sits on a darker walnut background instead of
     * the original cream `#faf7e8`. The wood-skinned panels and cards
     * (border-image PNGs from the Sprout Lands UI pack) stay honey-tan,
     * so the look reads as "lighter wood panels resting on a darker
     * wood floor" — matches the pixel-art world the player walks in.
     *
     * Token use:
     *   --bg-root  : outer root container only (darker walnut)
     *   --bg-soft  : cards inside modals (honey-cream, preserves
     *                pre-2.0.38 card legibility — these sit over
     *                an already-honey wood panel)
     *   --bg-card  : input fields, light pop-ups
     *   --bg-deep  : header strip + small accents (mid-walnut, ties
     *                root and panels visually)
     */
    --bg-root: #8b6f47;
    --bg-deep: #a5855c;
    --bg-soft: #f2e6c8;
    --bg-card: #ffffff;
    --border-warm: #5c4222;
    --border-soft: #a8835c;
    --accent: #6b8e23;
    --accent-dark: #4a6818;
    --text: #2b2014;
    --text-on-dark: #fff4d4;
    --text-muted: #6b5536;
    --text-muted-on-dark: #d9c294;

    box-sizing: border-box;
    max-width: 100%;
    margin: 0 auto;
    padding: 0.5rem;
    /* v2.0.24: the farm world is pixel-art and the UI is now wood-skinned,
     * so the text uses the bundled Cubic 11 (俐方體11號) pixel font — a
     * dot-matrix typeface with full Traditional-Chinese coverage (4800+
     * chars), already loaded on the page via mg-core's @font-face. This
     * is the pixel FONT, not the dark "arcade theme" chrome — it completes
     * the farm's own look. Falls back to Noto Sans CJK TC / system sans
     * for any rare glyph the pixel font lacks. */
    font-family: "Cubic 11", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK TC", sans-serif;
    color: var(--text);
    background: var(--bg-root);
    border-radius: 12px;
    border: 2px solid var(--border-warm);
    box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.18),
                inset 0 -2px 6px rgba(0, 0, 0, 0.25);
    /* v2.0.96 — block text selection + tap-highlight across the
       whole farm UI. Previously only .mg-farm-scene had this, so
       the action panel + sidebar + buttons would still trigger
       Firefox-mobile's text-selection highlight under sustained
       touch (e.g. holding to fish). Visible as a blue/teal tint
       across the page during the mini-game. */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.mg-farm-root *,
.mg-farm-root *::before,
.mg-farm-root *::after {
    box-sizing: inherit;
}

/* v2.0.282 — defensive: the user's site theme injects a global focus
 * outline (blue) with !important. Any focusable element inside the
 * scene (the scene itself + plot cells, both tabindex) would pick it
 * up, and since the scene fills the frame the blue hugged the whole
 * game UI. Neutralise plain :focus / :focus-within inside the scene
 * here; the scene + cell rules below restore an olive ring for
 * keyboard :focus-visible. Inputs/buttons keep their own rings. */
.mg-farm-scene:focus,
.mg-farm-scene:focus-within,
.mg-farm-scene *:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* v2.0.283 — the blue ring the user kept seeing hugs the OUTERMOST box
 * (outside the brown chrome), and appears "when a button is pressed".
 * That is the site theme painting a :focus / :focus-within outline on
 * the farm ROOT + its viewport wrappers — NOT the scene (2.0.281/282
 * only reset the scene, which is why it persisted). These container
 * elements should NEVER show a focus ring (they're layout wrappers,
 * not interactive controls). Hard-reset :focus AND :focus-within on
 * the whole wrapper chain. Interactive children (buttons, inputs,
 * cells) keep their own :focus-visible rings via the rules elsewhere. */
.mg-farm-root,
.mg-farm-root:focus,
.mg-farm-root:focus-within,
.mg-farm-root:focus-visible,
.mg-farm-viewport-outer,
.mg-farm-viewport-outer:focus,
.mg-farm-viewport-outer:focus-within,
.mg-farm-viewport,
.mg-farm-viewport:focus,
.mg-farm-viewport:focus-within {
    outline: none !important;
    box-shadow: none !important;
}
/* The shortcode wraps the farm in .mg-frame — kill its focus ring too,
 * scoped to the farm so other games' frames are untouched. */
.mg-frame[data-mg-game="farm"]:focus,
.mg-frame[data-mg-game="farm"]:focus-within,
.mg-frame--ported:has(> .mg-farm-root):focus,
.mg-frame--ported:has(> .mg-farm-root):focus-within {
    outline: none !important;
    box-shadow: none !important;
}

/* ---------- Header ----------
 *
 * v2.0.38 — sits directly on the dark walnut root bg, so use the
 * light-on-dark text tokens here (not the default --text used inside
 * wood-skinned panels). */

.mg-farm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.6rem;
    /* v2.0.261 — Adopted from .mg-farm-visit-banner. User feedback:
     * 「我想用探訪別人時顯示的header的背景（有gradient這個）替換
     * 自己農場時顯示的那個，這個好看 取代顯示菜幣的那個 background」
     * — i.e. visit-mode banner's warm brown gradient reads better
     * than own-farm's flat --bg-deep dark walnut, so unify them.
     *
     * Three values lifted from .mg-farm-visit-banner verbatim:
     *   - gradient background (150→120 warm brown, 95% opacity
     *     so subtle root bg shows through)
     *   - 2px (was 1px) warm border, slightly more presence
     *   - 0.25 / 0.2 highlight+shadow (was 0.20 / 0.15)
     *
     * Padding / margin / radius / flex layout unchanged — header
     * carries more children (currency + lifetime + rename + sfx +
     * music) than the slim banner, so its sizing rules stay. */
    background: linear-gradient(180deg,
        rgba(150, 110, 60, 0.95) 0%,
        rgba(120,  86, 44, 0.95) 100%);
    border: 2px solid var(--border-warm);
    border-radius: 6px;
    color: var(--text-on-dark);
    box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.25),
                0 1px 0 rgba(0, 0, 0, 0.2);
}
.mg-farm-currency {
    display: flex; align-items: center; gap: 0.35rem;
    font-size: 1.05rem; font-weight: 600;
    color: var(--text-on-dark);
}
.mg-farm-coin-icon { width: 20px; height: 20px; image-rendering: pixelated; }
.mg-farm-currency-amount { font-variant-numeric: tabular-nums; min-width: 3ch; }
.mg-farm-currency-name { color: var(--text-muted-on-dark); font-weight: 400; font-size: 0.95rem; }
.mg-farm-rename-btn {
    /* v2.0.42 — same site-theme-hijack lockdown as .mg-farm-rename-input
     * (see 2.0.41 notes there). Site themes inject e.g.
     *   button:hover { border-color: red !important; background: red ... }
     * which won was overriding the soft cream hover ring. Defence:
     * border:0 !important kills any colour they paint, the "border" is
     * drawn via inset box-shadow (much rarer to override), and all the
     * paint-related properties get explicit !important values to win
     * cascade against site rules of any specificity.
     *
     * The :hover ring is now box-shadow inset on top of the base ring
     * so hover deepens the cream tone without ever exposing a real
     * border for the site theme to colour. */
    background: rgba(255, 244, 212, 0.10) !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: inset 0 0 0 1px rgba(255, 244, 212, 0.35);
    border-radius: 4px;
    width: 22px; height: 22px; line-height: 1; cursor: pointer; padding: 0;
    font-size: 0.85rem;
    color: var(--text-on-dark) !important;
    -webkit-text-fill-color: var(--text-on-dark);
    transition: background 0.15s, box-shadow 0.15s;
}
.mg-farm-root .mg-farm-rename-btn:hover,
.mg-farm-root .mg-farm-rename-btn:focus,
.mg-farm-root .mg-farm-rename-btn:focus-visible,
.mg-farm-root .mg-farm-rename-btn:active {
    background: rgba(255, 244, 212, 0.22) !important;
    border: 0 !important;
    outline: 0 !important;
    color: var(--text-on-dark) !important;
    -webkit-text-fill-color: var(--text-on-dark);
    box-shadow: inset 0 0 0 1px rgba(255, 244, 212, 0.55) !important;
}
.mg-farm-lifetime { font-size: 0.85rem; color: var(--text-muted-on-dark); }
.mg-farm-lifetime-amount { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-on-dark); }

/* v2.0.134 — SFX on/off toggle (header ♪). Same site-theme lockdown as
 * the rename button so injected `button{}` rules can't recolour it.
 * .is-off dims the glyph and strikes a line through it.
 * v2.0.233 — character ♪ replaced by <span class="mg-ic mg-ic-note">
 * (pixel art 8×12). Padding adjusted so the icon centers in 24×24. */
.mg-farm-sfx-toggle,
.mg-farm-music-toggle {
    background: rgba(255, 244, 212, 0.10) !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: inset 0 0 0 1px rgba(255, 244, 212, 0.35);
    border-radius: 4px;
    width: 24px; height: 24px; line-height: 1; cursor: pointer; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-on-dark) !important;
    -webkit-text-fill-color: var(--text-on-dark);
    position: relative;
    transition: background 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.mg-farm-sfx-toggle .mg-ic-note {
    width: 10px; height: 14px;
    margin: 0;
    /* Tint the note to match the header text colour by recolouring
     * via filter (the source PNG is dark brown so it'd be invisible
     * on a dark header). brightness inverts to near-white. */
    filter: brightness(0) invert(0.93) sepia(0.15);
}
/* v2.0.238 — header music (農場電台) toggle, sits to the LEFT of the
 * SFX toggle. Same wood-bar chrome as .mg-farm-sfx-toggle (grouped
 * above); only the icon differs — two eighth notes (♫) vs the single
 * ♪ used for SFX. Same near-white tint so both match the header text. */
.mg-farm-music-toggle .mg-ic-note2 {
    width: 14px; height: 14px;
    margin: 0;
    filter: brightness(0) invert(0.93) sepia(0.15);
}
/* v2.0.240 — group the two header toggles so the header's
 * justify-content:space-between treats them as ONE right-aligned unit
 * (previously they were separate flex children and got spread apart,
 * leaving a big empty gap between ♫ and ♪). Inside, a tight 4px gap
 * keeps them reading as a button pair. */
.mg-farm-header-toggles {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.mg-farm-root .mg-farm-sfx-toggle:hover,
.mg-farm-root .mg-farm-sfx-toggle:focus,
.mg-farm-root .mg-farm-sfx-toggle:focus-visible,
.mg-farm-root .mg-farm-sfx-toggle:active,
.mg-farm-root .mg-farm-music-toggle:hover,
.mg-farm-root .mg-farm-music-toggle:focus,
.mg-farm-root .mg-farm-music-toggle:focus-visible,
.mg-farm-root .mg-farm-music-toggle:active {
    background: rgba(255, 244, 212, 0.22) !important;
    border: 0 !important;
    outline: 0 !important;
    color: var(--text-on-dark) !important;
    -webkit-text-fill-color: var(--text-on-dark);
    box-shadow: inset 0 0 0 1px rgba(255, 244, 212, 0.55) !important;
}
.mg-farm-sfx-toggle.is-off,
.mg-farm-music-toggle.is-off { opacity: 0.45; }
.mg-farm-sfx-toggle.is-off::after,
.mg-farm-music-toggle.is-off::after {
    content: "";
    position: absolute;
    left: 3px; right: 3px; top: 50%;
    height: 2px;
    background: var(--text-on-dark);
    transform: rotate(-20deg);
    transform-origin: center;
    pointer-events: none;
}

/* v2.0.135 — the farm now has its own ♪ SFX toggle in the header, so
 * the shared framework sound button (class-mg-shortcode renders a
 * .mg-sound-toggle into every .mg-frame) is redundant here. Hide it
 * for the farm ONLY — scoped via the frame's data-mg-game so every
 * other game keeps its button untouched. !important is required to
 * beat core.css's `display: inline-flex !important` base rule. The
 * music toggle is left alone (not rendered for farm anyway, and is
 * reserved for the upcoming in-farm music player). */
.mg-frame[data-mg-game="farm"] .mg-sound-toggle { display: none !important; }

/* ===== v2.0.136 — in-farm radio sprite + music player ===== */

/* CSS-drawn pixel radio sitting in the scene (swap for a PNG later).
 * v2.0.139 — the v2.0.138 fix was wrong: `.mg-farm-radio` and
 * `.mg-farm-scene-chrome > *` (which sets pointer-events: none on chrome
 * children) are tied at specificity (0,1,0), and the chrome rule comes
 * later in source so it wins. Bumping to a descendant-with-child
 * selector below brings my rule to (0,2,0) and cleanly out-specifies
 * the chrome rule. */
.mg-farm-radio { cursor: pointer; }
.mg-farm-scene-chrome > .mg-farm-radio { pointer-events: auto; }
/* v2.0.202 — animal sprites (cow, chickens) need direct click-receive too.
 * Without this they inherit `pointer-events: none` from `.mg-farm-scene-chrome > *`,
 * so clicks PASS THROUGH the visible sprite, fall to the empty-scene-click
 * fallback (pixel÷cell math), then route via player-arrival-adjacency. That
 * indirect path mis-fires constantly:
 *   - cow is 2×2 sprite; sub-pixel + camera-transform jitter on the upper
 *     half can compute a cell coord ABOVE the cow → adjacent chicken's
 *     slot opens instead.
 *   - chicken wanders; click on a chicken's current visual cell ≠ chicken's
 *     SLOT cell, so adjacency check finds the wrong slot.
 * Direct pointer-events:auto routes the click straight to the sprite element;
 * `closest('[data-mg-animal-slot]')` resolves to the right slot id; click
 * handler calls walkTo(slot.x, slot.y) — exact match, no cell math involved.
 * Same specificity bump as the .mg-farm-radio rule above (descendant-with-
 * child selector beats the chrome rule). */
.mg-farm-scene-chrome > [data-mg-animal-slot] {
    pointer-events: auto;
    cursor: pointer;
}
.mg-farm-radio .mg-farm-radio-body {
    position: absolute; left: 14%; right: 14%; bottom: 6%; height: 60%;
    background: #8a5a30; border: 2px solid #5a3d24; border-radius: 5px;
    box-shadow: inset 0 2px 0 rgba(255, 235, 200, 0.25), inset 0 -3px 4px rgba(74, 49, 32, 0.40);
    image-rendering: pixelated;
}
.mg-farm-radio .mg-farm-radio-speaker {
    position: absolute; left: 12%; top: 24%; width: 40%; height: 52%; border-radius: 50%;
    background: #3b2814; box-shadow: inset 0 0 0 2px #6e4d30;
}
.mg-farm-radio .mg-farm-radio-knobs { position: absolute; right: 12%; top: 22%; display: flex; flex-direction: column; gap: 5px; }
.mg-farm-radio .mg-farm-radio-knobs i { width: 7px; height: 7px; border-radius: 50%; background: #f3d9a8; box-shadow: inset 0 -1px 0 rgba(74, 49, 32, 0.5); }
.mg-farm-radio .mg-farm-radio-note {
    /* v2.0.233 — was font-character ♪; now a small pixel-art sprite
     * (note.png 8×12) sized down to 6×9 to fit the tiny radio body.
     * filter recolours the dark-brown source to the warm cream that
     * used to come from `color: #f3d9a8;`. */
    position: absolute; right: 13%; bottom: 10%;
    width: 6px; height: 9px;
    background-image: url("assets/ui/emoji/note.png");
    background-size: contain; background-repeat: no-repeat;
    image-rendering: pixelated;
    filter: brightness(0) invert(0.93) sepia(0.40) hue-rotate(-15deg) saturate(2);
    opacity: 0.35;
}
.mg-farm-radio .mg-farm-radio-ant { position: absolute; right: 22%; top: -30%; width: 2px; height: 32%; background: #5a3d24; transform: rotate(22deg); transform-origin: bottom; }
@keyframes mg-farm-radio-pulse { 0%, 100% { opacity: 0.55; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
/* v2.0.137 — when music is playing, the ♪ note brightens + pulses, and a
 * subtle sound wave ring expands out of the speaker. When music is paused
 * the radio sits calm (no animation), so the in-scene sprite acts as an
 * ambient "is music on?" indicator even with the player popup closed. */
.mg-farm-radio.mg-is-playing .mg-farm-radio-note {
    opacity: 1;
    animation: mg-farm-radio-pulse 1.8s ease-in-out infinite;
}
.mg-farm-radio.mg-is-playing::before {
    content: ""; position: absolute;
    left: 22%; top: 38%; width: 22%; height: 22%;
    border-radius: 50%;
    border: 1.5px solid rgba(243, 217, 168, 0);
    pointer-events: none;
    animation: mg-farm-radio-wave 1.8s ease-out infinite;
}
@keyframes mg-farm-radio-wave {
    0%   { transform: scale(0.5); border-color: rgba(243, 217, 168, 0.85); opacity: 1; }
    100% { transform: scale(2.6); border-color: rgba(243, 217, 168, 0);    opacity: 0; }
}
.mg-farm-radio:hover .mg-farm-radio-body,
.mg-farm-radio:focus-visible .mg-farm-radio-body { box-shadow: inset 0 2px 0 rgba(255, 235, 200, 0.35), 0 0 0 2px rgba(255, 235, 200, 0.55); }

/* Music player (rendered inside the wood modal). */
/* v2.0.148 — 2-column grid: playlist (left, inset/recessed) | player (right,
 * with raised now-playing card). Foot spans both columns at the bottom.
 * Right column slightly wider (1.3fr) so the now-playing name + controls
 * don't crowd. min-width bumped from 260 → 300 to keep both columns usable
 * on the narrowest phones; the modal already centres + shrinks gracefully. */
.mg-farm-mp {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) minmax(140px, 1.3fr);
    gap: 12px;
    color: #5a3d24;
    min-width: 300px;
}
/* Left column — playlist container with INSET/RECESSED look for layered
 * depth (sits "into" the modal). Combination of dark inset on top-left
 * + warm highlight on bottom-right reads as a carved-out panel in wood. */
.mg-farm-mp-left {
    background: rgba(70, 50, 30, 0.13);
    border-radius: 6px;
    padding: 6px 4px;
    box-shadow: inset 0 1px 2px rgba(74, 49, 32, 0.30),
                inset 0 -1px 0 rgba(255, 235, 200, 0.20);
}
/* Right column — vertical stack of now-playing card + controls + volume.
 * No background of its own (sits on the modal); the .mg-farm-mp-now child
 * inside is the raised element that anchors visual hierarchy. */
.mg-farm-mp-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mg-farm-mp-now {
    /* v2.0.148 — promoted from a flat tinted strip to a RAISED card.
     * v2.0.234 — replaced the gradient + soft shadow stack with a
     * flat-2-color pixel-style: solid warm tint + 1px pixel border
     * (no border-radius — sharp corners matching the rest of the
     * pixel UI), and a 1px hard inset highlight instead of the
     * earlier blurred drop shadow. Reads as a wooden plank label. */
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    background: #e8d4a8;
    border: 1px solid #4a3120;
    box-shadow: inset 0 1px 0 #f7ecd5,
                inset 0 -1px 0 #a08055;
}
/* v2.0.137 — small spinning vinyl disc on the left of the now-playing row.
 * v2.0.234 — replaced the multi-stop radial gradient (read as smooth/AA
 * vs the rest of the pixel UI) with vinyl.png, a hand-painted 13×13
 * pixel-art disc. CSS spin animation still applies; on a small element
 * the rotation reads as "spinning" without obvious anti-aliasing because
 * the body is rotationally symmetric — only the off-centre highlight
 * notch sells the motion. */
.mg-farm-mp-vinyl {
    width: 26px; height: 26px; flex: 0 0 auto;
    background-image: url("assets/ui/vinyl.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
}
.mg-farm-mp-vinyl.is-playing { animation: mg-farm-mp-vinyl-spin 3s linear infinite; }
@keyframes mg-farm-mp-vinyl-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.mg-farm-mp-nowname { font-size: 0.95rem; font-weight: 600; color: #3b2814; flex: 1 1 auto; }
.mg-farm-mp-eq { display: flex; align-items: flex-end; gap: 2px; height: 14px; flex: 0 0 auto; }
.mg-farm-mp-eq i { width: 3px; height: 4px; background: #5a3d24; }
.mg-farm-mp-eq.is-playing i { animation: mg-farm-mp-eq 0.9s ease-in-out infinite; }
.mg-farm-mp-eq.is-playing i:nth-child(2) { animation-delay: 0.3s; }
.mg-farm-mp-eq.is-playing i:nth-child(3) { animation-delay: 0.6s; }
@keyframes mg-farm-mp-eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }
.mg-farm-mp-ctrls { display: flex; justify-content: center; gap: 8px; }
.mg-farm-mp-btn { width: 36px; height: 26px; cursor: pointer; background: none; padding: 0;
    border: 6px solid transparent;
    border-image: url("assets/ui/btn.png") 6 6 8 6 fill / 6px 6px 8px 6px / 0 stretch;
    display: inline-flex; align-items: center; justify-content: center; image-rendering: pixelated; }
/* v2.0.149 — control icons rewritten as true pixel-art via SVG mask
 * (7×7 grid, shape-rendering: crispEdges). Pre-2.0.149 they were CSS
 * border-triangles which give smooth anti-aliased edges that clash with
 * the pixel-art UI. Now each icon is a stepped grid of 1×1 blocks
 * masked over a solid fill (#5a3d24 = wood brown). Layouts:
 *
 *   Play (▶)   Pause (||)    Prev (|◀)    Next (▶|)
 *   █·······   ·██·██·       █····█·       █·····█
 *   ██······   ·██·██·       █···██·       ██····█
 *   ███·····   ·██·██·       █··███·       ███···█
 *   ████····   ·██·██·       █·████·       ████··█
 *   ███·····   ·██·██·       █··███·       ███···█
 *   ██······   ·██·██·       █···██·       ██····█
 *   █·······   ·██·██·       █····█·       █·····█
 */
.mg-farm-mp-ico-play,
.mg-farm-mp-ico-pause,
.mg-farm-mp-ico-prev,
.mg-farm-mp-ico-next {
    display: inline-block;
    width: 14px; height: 14px;
    background-color: #5a3d24;
    -webkit-mask-size: contain;        mask-size: contain;
    -webkit-mask-position: center;     mask-position: center;
    -webkit-mask-repeat: no-repeat;    mask-repeat: no-repeat;
}
/* v2.0.161 — play triangle optically centered. A right-pointing triangle's
 * visual mass sits on its (left) base; drawn at x=0 its centroid was ~1.38 in
 * the 7-wide grid while the button centers the viewBox at 3.5 → looked shifted
 * left. Pause (symmetric) was unaffected. Nudged +1px: centroid ~2.38 — leaves
 * a touch more breathing room on the right (preferred over +2's tight apex).
 * Stays on the integer pixel grid so crispEdges stays crisp (no transform blur). */
.mg-farm-mp-ico-play {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='black'><rect x='1' y='0' width='1' height='1'/><rect x='1' y='1' width='2' height='1'/><rect x='1' y='2' width='3' height='1'/><rect x='1' y='3' width='4' height='1'/><rect x='1' y='4' width='3' height='1'/><rect x='1' y='5' width='2' height='1'/><rect x='1' y='6' width='1' height='1'/></svg>");
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='black'><rect x='1' y='0' width='1' height='1'/><rect x='1' y='1' width='2' height='1'/><rect x='1' y='2' width='3' height='1'/><rect x='1' y='3' width='4' height='1'/><rect x='1' y='4' width='3' height='1'/><rect x='1' y='5' width='2' height='1'/><rect x='1' y='6' width='1' height='1'/></svg>");
}
.mg-farm-mp-ico-pause {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='black'><rect x='1' y='0' width='2' height='7'/><rect x='4' y='0' width='2' height='7'/></svg>");
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='black'><rect x='1' y='0' width='2' height='7'/><rect x='4' y='0' width='2' height='7'/></svg>");
}
.mg-farm-mp-ico-prev {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='black'><rect x='0' y='0' width='1' height='7'/><rect x='5' y='0' width='1' height='1'/><rect x='4' y='1' width='2' height='1'/><rect x='3' y='2' width='3' height='1'/><rect x='2' y='3' width='4' height='1'/><rect x='3' y='4' width='3' height='1'/><rect x='4' y='5' width='2' height='1'/><rect x='5' y='6' width='1' height='1'/></svg>");
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='black'><rect x='0' y='0' width='1' height='7'/><rect x='5' y='0' width='1' height='1'/><rect x='4' y='1' width='2' height='1'/><rect x='3' y='2' width='3' height='1'/><rect x='2' y='3' width='4' height='1'/><rect x='3' y='4' width='3' height='1'/><rect x='4' y='5' width='2' height='1'/><rect x='5' y='6' width='1' height='1'/></svg>");
}
.mg-farm-mp-ico-next {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='black'><rect x='0' y='0' width='1' height='1'/><rect x='0' y='1' width='2' height='1'/><rect x='0' y='2' width='3' height='1'/><rect x='0' y='3' width='4' height='1'/><rect x='0' y='4' width='3' height='1'/><rect x='0' y='5' width='2' height='1'/><rect x='0' y='6' width='1' height='1'/><rect x='6' y='0' width='1' height='7'/></svg>");
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='black'><rect x='0' y='0' width='1' height='1'/><rect x='0' y='1' width='2' height='1'/><rect x='0' y='2' width='3' height='1'/><rect x='0' y='3' width='4' height='1'/><rect x='0' y='4' width='3' height='1'/><rect x='0' y='5' width='2' height='1'/><rect x='0' y='6' width='1' height='1'/><rect x='6' y='0' width='1' height='7'/></svg>");
}
/* v2.0.137 — wood-grain horizontal volume slider. Custom-styled native
 * <input type=range> so we get free keyboard + drag + a11y. v2.0.234 —
 * gradients on track + radial thumb gone; replaced with 2-color flat
 * pixel-stepped wood (darker plank top edge + main plank body) and a
 * square pixel-wood thumb. Sharp corners, no border-radius, no blur
 * shadows — matches the rest of the pixel UI. */
.mg-farm-mp-vol { display: flex; align-items: center; gap: 10px; margin: 0 2px; }
/* v2.0.148 — .mg-farm-mp-vol-ico rule removed; the ♪ glyph in front of
 * the slider was removed from HTML (clashed with pixel art). Slider
 * alone is self-explanatory in context. */
.mg-farm-mp-vol-slider {
    flex: 1 1 auto; height: 10px; margin: 0; padding: 0;
    -webkit-appearance: none; appearance: none;
    background: #6e4d30;
    border: 1px solid #4a3120;
    box-shadow: inset 0 1px 0 #8a5a30,
                inset 0 -1px 0 #4a3120;
    outline: none; cursor: pointer;
    image-rendering: pixelated;
}
.mg-farm-mp-vol-slider:focus-visible {
    box-shadow: inset 0 1px 0 #8a5a30, inset 0 -1px 0 #4a3120,
                0 0 0 2px #f7ecd5;
}
.mg-farm-mp-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 12px; height: 16px;
    background: #c89060;
    border: 1px solid #4a3120;
    box-shadow: inset 0 1px 0 #e0b485,
                inset 0 -1px 0 #6e4d30;
    cursor: grab;
}
.mg-farm-mp-vol-slider::-webkit-slider-thumb:active { cursor: grabbing; }
.mg-farm-mp-vol-slider::-moz-range-thumb {
    width: 12px; height: 16px;
    background: #c89060;
    border: 1px solid #4a3120;
    box-shadow: inset 0 1px 0 #e0b485,
                inset 0 -1px 0 #6e4d30;
    cursor: grab;
}
.mg-farm-mp-list { display: flex; flex-direction: column; gap: 1px; }
.mg-farm-mp-song { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 5px; font-size: 0.9rem; cursor: pointer; }
.mg-farm-mp-song:hover { background: rgba(120, 86, 45, 0.10); }
.mg-farm-mp-song.on {
    /* v2.0.148 — left wood-bar inset replaces the right-side ♪ glyph
     * as the "currently playing" indicator. 3px inset shadow on the
     * left edge reads as a wood accent rail, consistent with how DAWs
     * highlight the active track. ♪ HTML span deleted from JS render. */
    background: rgba(120, 86, 45, 0.22);
    font-weight: 600;
    color: #3b2814;
    box-shadow: inset 3px 0 0 #8a5a30;
}
/* peg dot — matches the v2.0.133 wood-rivet look */
.mg-farm-mp-peg { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto;
    background: radial-gradient(circle at 40% 35%, #6e4d30 0%, #4a3120 58%, rgba(74, 49, 32, 0) 66%); }
.mg-farm-mp-song.on .mg-farm-mp-peg { box-shadow: 0 0 0 2px rgba(110, 77, 48, 0.40); }
.mg-farm-mp-songname { flex: 1 1 auto; }
/* v2.0.148 — .mg-farm-mp-playing + mg-farm-mp-row-pulse keyframes
 * removed. Indicator is now the left wood-bar inset shadow on
 * .mg-farm-mp-song.on (above). */
.mg-farm-mp-foot {
    grid-column: 1 / -1;  /* span both columns at the bottom of the grid */
    margin-top: 4px;
    font-size: 0.75rem;
    color: #9a7a4f;
    text-align: center;
}

/* ---------- Viewport + Scene ----------
 *
 * The viewport is a fixed-size box (12×8 cells × 96px = 1152×768 native);
 * JS sets `transform: scale(<fitFactor>)` on the wrapper to fit it to the
 * available container width, with transform-origin top-left so the
 * scaled viewport occupies the same top-left position.
 *
 * Aspect-ratio reservation: the wrapper carries `aspect-ratio: 12/8` so
 * the surrounding layout reserves the correct vertical space even
 * before JS scales it.
 */

.mg-farm-viewport-outer {
    position: relative;
    width: 100%;
    max-width: calc(var(--viewport-cols) * var(--cell));
    aspect-ratio: var(--viewport-cols) / var(--viewport-rows);
    margin: 0 auto 0.6rem;
    overflow: hidden;
    border-radius: 6px;
    /* v2.0.186 — border colour follows the active layout's accent (see
     * LAYOUT_PICKER_HINT in farm.js, mirrored onto --viewport-accent by
     * applyViewportAccent()). Smooth crossfade on layout swap. */
    box-shadow: 0 0 0 2px var(--viewport-accent, #6a9050);
    transition: box-shadow 1.2s ease-in-out;
}

.mg-farm-viewport {
    position: absolute;
    inset: 0;
    width: calc(var(--viewport-cols) * var(--cell));
    height: calc(var(--viewport-rows) * var(--cell));
    overflow: hidden;
    /* JS-set: transform: scale(<fit>); transform-origin: 0 0 */
    transform-origin: 0 0;
    background: #93c477;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.mg-farm-scene {
    position: absolute;
    width:  calc(var(--scene-cols) * var(--cell));
    height: calc(var(--scene-rows) * var(--cell));
    /* JS-set: transform: translate(-cameraX, -cameraY) */
    transform: translate(0, 0);
    transition: transform 0.18s linear;
    image-rendering: inherit;
}
/* v2.0.281 — the scene + cells carry tabindex for keyboard play, so
 * the browser draws its DEFAULT focus ring (blue on Chromium/Android)
 * around them — and because the scene fills the frame, that blue ring
 * hugged the whole game UI on tap/click (user screenshot).
 * v2.0.282 — the user's site theme also injects a global focus
 * outline (same class of attack as its button:hover{...red} rule),
 * which has !important and beat the plain `outline:none`. Harden with
 * !important + cover :focus-within (site themes often target the
 * focusable ancestor). Only :focus-visible (keyboard nav) shows a ring
 * — in the farm olive, never the browser/site blue. */
.mg-farm-scene:focus,
.mg-farm-scene:focus-within {
    outline: none !important;
    box-shadow: none !important;
}
.mg-farm-scene:focus-visible {
    outline: 3px solid var(--accent, #6b8e23) !important;
    outline-offset: -3px;
}

.mg-farm-scene > * {
    position: absolute;
    image-rendering: inherit;
}

.mg-farm-scene-bg {
    inset: 0;
    /* v2.0.4: grass.png is now a single 16×16 PNG of pure green
       grass (extracted from Premium pack's Grass_tiles_v2_Mid.png).
       background-size = cell px → each repeat is exactly one cell.
       background-repeat tiles it across the full scene. No
       offset math, no sheet leakage possible. */
    background-image: url("assets/tiles/grass.png");
    background-size: var(--cell) var(--cell);
    background-repeat: repeat;
}

/* Scene-positioned children use --x/--y/--w/--h (in cells) */
.mg-farm-scene-chrome > *,
.mg-farm-scene-npc > *,
.mg-farm-player {
    position: absolute;
    left: calc(var(--x, 0) * var(--cell));
    top:  calc(var(--y, 0) * var(--cell));
    width:  calc(var(--w, 1) * var(--cell));
    height: calc(var(--h, 1) * var(--cell));
    background-repeat: no-repeat;
    pointer-events: none;
}

.mg-farm-scene-npc > * {
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.15s;
}

/* v2.0.52 — live chickens. They glide between pen cells via a left/top
   transition (duration matches CHICKEN_WALK_MS in farm.js), and flip
   horizontally (transform: scaleX(-1)) to face their travel direction.
   transform is reserved for the flip only — position uses left/top — so
   the two never conflict. */
.mg-farm-chicken {
    transition: left 0.48s linear, top 0.48s linear;
    transform-origin: 50% 80%;
    will-change: left, top;
}
.mg-farm-scene-npc > *:hover { transform: scale(1.06); }

/* v2.0.14: NPC indicator is a speech bubble (not a "!" badge).
   White rounded bubble with "…" inside + a little tail at the bottom,
   so it reads as "this NPC can talk / has a shop" rather than an alert. */
.mg-farm-scene-npc > *::after {
    content: '\2026';   /* … horizontal ellipsis = "talk to me" */
    position: absolute;
    top: -1.5em; left: 50%;
    transform: translateX(-50%);
    min-width: 1.5em; height: 1.2em;
    padding: 0 0.25em;
    background: #fffdf5;
    border: 2px solid #4a3818;
    border-radius: 0.55em;
    color: #4a3818;
    font-weight: 700; font-size: 0.95em; line-height: 1.1;
    letter-spacing: 0.05em;
    text-align: center;
    image-rendering: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
    animation: mg-farm-bob 1.4s ease-in-out infinite;
    pointer-events: none;
}
/* Bubble tail — a small triangle pointing down from the bubble's
   bottom-left, drawn with a rotated square sharing the bubble's border. */
.mg-farm-scene-npc > *::before {
    content: '';
    position: absolute;
    top: -0.55em; left: 50%;
    transform: translateX(-90%) rotate(45deg);
    width: 0.45em; height: 0.45em;
    background: #fffdf5;
    border-right: 2px solid #4a3818;
    border-bottom: 2px solid #4a3818;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.10);
    animation: mg-farm-bob 1.4s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}
@keyframes mg-farm-bob {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50%      { transform: translateX(-50%) translateY(-6px); }
}
/* The tail bobs with the bubble but keeps its own rotate. */
@keyframes mg-farm-bob-tail {
    0%, 100% { transform: translateX(-90%) rotate(45deg) translateY(0); }
    50%      { transform: translateX(-90%) rotate(45deg) translateY(-6px); }
}
.mg-farm-scene-npc > *::before {
    animation-name: mg-farm-bob-tail;
}
/* Disabled NPCs (e.g. Phase-2 mail, not yet interactive) show neither
   the speech bubble nor its tail — a bubble would imply you can talk. */
.mg-farm-scene-npc > .is-disabled::after,
.mg-farm-scene-npc > .is-disabled::before {
    display: none;
}

/* ---------- Plot inside scene ---------- */

.mg-farm-plot {
    /* v2.0.54 — scattered blocks. The plot container now spans the whole
       scene; individual cells are absolutely placed at their scene coords
       (--cx / --cy, set by JS from each cell's relative data-x/data-y).
       The old single CSS-grid + one fence frame is gone — each cell gets
       its own thin wooden edge so the scattered 3×2 fields read as tilled
       patches. */
    left: 0;
    top:  0;
    width:  calc(var(--scene-cols) * var(--cell));
    height: calc(var(--scene-rows) * var(--cell));
    z-index: 5;
}

.mg-farm-cell {
    position: absolute;
    left: calc(var(--cx, 0) * var(--cell));
    top:  calc(var(--cy, 0) * var(--cell));
    width:  var(--cell);
    height: var(--cell);
    background-repeat: no-repeat;
    background-position: center;
    background-size: var(--cell) var(--cell);
    image-rendering: pixelated;
    cursor: pointer;
    user-select: none;
    transition: filter 0.1s ease-out;
}
.mg-farm-cell:hover { filter: brightness(1.1); }
/* v2.0.281/282 — same as the scene: kill the default/site-theme focus
 * ring on tap/click (with !important to beat the site theme's global
 * focus outline), keep an olive ring only for keyboard :focus-visible. */
.mg-farm-cell:focus,
.mg-farm-cell:focus-within {
    outline: none !important;
    box-shadow: none !important;
}
.mg-farm-cell:focus-visible {
    outline: 3px solid var(--accent, #6b8e23) !important;
    outline-offset: -3px;
}

.mg-farm-cell.is-locked { cursor: not-allowed; }
.mg-farm-cell.is-locked::after {
    /* v2.0.147 — switched from self-drawn lock.png to Sprout Lands'
     * official close.png (X). Matches the `.mg-ic-lock` swap in
     * v2.0.146; "X over a darkened cell" reads as "denied / not yours
     * yet" consistently across the whole UI (locked seeds, locked
     * trees, locked plot cells). */
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(80, 60, 40, 0.55) url("assets/ui/emoji/close.png") center / 38% no-repeat;
    image-rendering: pixelated;
}

/* v2.0.53 — unlocked but not yet tilled: bare ground (scene grass shows
   through) with a dashed brown outline + a small hoe hint so the player
   can see which cells still need hoeing before they can plant. */
.mg-farm-cell.is-untilled::after {
    /* v2.0.73/v2.0.75 — pixel hoe from the central emoji set. */
    /* v2.0.94 — bumped from 35% to 60% so the hoe reads at a glance
       on mobile (a single ~16-18px cell needs a larger anchor than
       a desktop view). Keeping aspect via center. */
    content: "";
    position: absolute;
    inset: 0;
    background: url("assets/ui/emoji/hoe.png") center / 60% no-repeat;
    image-rendering: pixelated;
    border: 3px dashed rgba(120, 86, 50, 0.55);
    border-radius: 4px;
    opacity: 0.6;
}
.mg-farm-cell.is-untilled:hover::after { opacity: 0.9; }

/* v2.0.54 — thin wooden edge on tilled soil so each scattered 3×2 field
   reads as a framed patch (the old single fence around the whole grid is
   gone now that blocks live in different parts of the farm). */
.mg-farm-cell.is-tilled {
    box-shadow: inset 0 0 0 2px rgba(107, 74, 42, 0.45);
}

/* v2.0.57 — block-tilling animation.
   Hoe swings once on the clicked cell; a brown puff fades across every
   cell in the 3×2 block (staggered ~70ms by JS via setTimeout). */
.mg-farm-till-hoe {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    pointer-events: none;
    z-index: 30;
    animation: mg-farm-hoe-swing 0.6s ease-out forwards;
    transform-origin: 30% 70%;
}
@keyframes mg-farm-hoe-swing {
      0% { transform: rotate(-35deg) scale(1.2); opacity: 0; }
     20% { transform: rotate(-35deg) scale(1.2); opacity: 1; }
     55% { transform: rotate(  25deg) scale(1.1); opacity: 1; }
     85% { transform: rotate(  10deg) scale(1);   opacity: 0.7; }
    100% { transform: rotate(   0deg) scale(0.9); opacity: 0; }
}
.mg-farm-till-puff {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 25;
    background: radial-gradient(circle at 50% 60%,
                rgba(120, 85, 45, 0.85) 0%,
                rgba(120, 85, 45, 0.55) 35%,
                rgba(120, 85, 45, 0) 75%);
    border-radius: 50%;
    animation: mg-farm-puff 0.52s ease-out forwards;
}
@keyframes mg-farm-puff {
      0% { transform: scale(0.3); opacity: 0; }
     25% { transform: scale(1.0); opacity: 0.95; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* v2.0.107 — water-puff: blue tinted variant of the dirt puff,
   spawned at the moment the player pours the watering can. */
.mg-farm-water-puff {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 25;
    background: radial-gradient(circle at 50% 60%,
                rgba(120, 175, 220, 0.85) 0%,
                rgba(120, 175, 220, 0.55) 35%,
                rgba(120, 175, 220, 0) 75%);
    border-radius: 50%;
    animation: mg-farm-puff 0.50s ease-out forwards;
}

/* v2.0.121 — Loading indicator. Deferred 200ms (set via JS) so fast
   actions don't trigger a visible spinner flash. 3-dot bouncing
   animation in a wood-toned pill near the top-right of the scene. */
.mg-farm-loading {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 90;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(60, 36, 20, 0.72);
    border: 1.5px solid rgba(168, 130, 75, 0.6);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 0.18s ease-out;
    pointer-events: none;
}
.mg-farm-loading.is-visible {
    display: flex;
    opacity: 1;
}
.mg-farm-loading-dot {
    width: 6px;
    height: 6px;
    background: #f5e8c8;
    border-radius: 50%;
    animation: mg-farm-loading-bounce 0.9s ease-in-out infinite;
}
.mg-farm-loading-dot:nth-child(2) { animation-delay: 0.15s; }
.mg-farm-loading-dot:nth-child(3) { animation-delay: 0.30s; }

@keyframes mg-farm-loading-bounce {
      0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* v2.0.121 — Slow-network hint. Appears at 5s mark to reassure
   the player the action hasn't been dropped. Cream-paper card
   styled to match the wood theme. */
.mg-farm-slow-hint {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 91;
    padding: 6px 14px;
    background: #f5e8c8;
    color: #5a4220;
    border: 1.5px solid #a8835c;
    border-radius: 8px;
    box-shadow: 0 2px 0 rgba(74, 50, 22, 0.18);
    font-size: 0.85rem;
    pointer-events: none;
    animation: mg-farm-slow-hint-fade 0.3s ease-out forwards;
}
@keyframes mg-farm-slow-hint-fade {
      0% { opacity: 0; transform: translate(-50%, -8px); }
    100% { opacity: 1; transform: translate(-50%, 0); }
}

/* v2.0.115 — Pouring watering can overlay. Uses 4 native artist-
   drawn pour poses from Sprout Lands' char_tools sheet (row 1),
   one per facing direction.
   v2.0.119 — 2-state animation: `.is-idle` shows the row-0 static
   can (raised, no water yet); `.is-pouring` swaps to the row-1
   pouring can (with water drop) when the puff fires on target. */
.mg-farm-water-can {
    position: absolute;
    left: calc(var(--x, 0) * var(--cell));
    top:  calc(var(--y, 0) * var(--cell));
    width:  var(--cell);
    height: var(--cell);
    pointer-events: none;
    z-index: 12;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    animation: mg-farm-can-fade 0.8s ease-out forwards;
}
/* DOWN: front-view, place below player */
.mg-farm-water-can--down.is-idle {
    background-image: url("assets/ui/watering_can_down_idle.png");
    background-size: 30% auto;
    background-position: 50% 88%;
}
.mg-farm-water-can--down.is-pouring {
    background-image: url("assets/ui/watering_can_down.png");
    background-size: 30% auto;
    background-position: 50% 92%;
}
/* UP: back-view, place above player */
.mg-farm-water-can--up.is-idle {
    background-image: url("assets/ui/watering_can_up_idle.png");
    background-size: 30% auto;
    background-position: 50% 12%;
}
.mg-farm-water-can--up.is-pouring {
    background-image: url("assets/ui/watering_can_up.png");
    background-size: 30% auto;
    background-position: 50% 8%;
}
/* RIGHT: side-view, place to player's right */
.mg-farm-water-can--right.is-idle {
    background-image: url("assets/ui/watering_can_right_idle.png");
    background-size: 45% auto;
    background-position: 92% 55%;
}
.mg-farm-water-can--right.is-pouring {
    background-image: url("assets/ui/watering_can_right.png");
    background-size: 50% auto;
    background-position: 95% 55%;
}
/* LEFT: side-view, place to player's left */
.mg-farm-water-can--left.is-idle {
    background-image: url("assets/ui/watering_can_left_idle.png");
    background-size: 45% auto;
    background-position: 8% 55%;
}
.mg-farm-water-can--left.is-pouring {
    background-image: url("assets/ui/watering_can_left.png");
    background-size: 50% auto;
    background-position: 5% 55%;
}
@keyframes mg-farm-can-fade {
      0% { opacity: 0; }
     15% { opacity: 1; }
     85% { opacity: 1; }
    100% { opacity: 0; }
}

/* v2.0.230 — ripe indicator now uses the pixel-art sparkle.png (matches
 * the icon pack) instead of the Unicode ✨ which broke the pixel-art
 * look. Sized + animated identically. */
.mg-farm-cell.is-ripe::before {
    content: "";
    position: absolute;
    top: 2px; right: 2px;
    width: 16px; height: 18px;
    background-image: url("assets/ui/emoji/sparkle.png");
    background-size: contain;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    animation: mg-farm-ripe-pulse 1.6s ease-in-out infinite;
}
@keyframes mg-farm-ripe-pulse {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50%      { transform: scale(1.18); opacity: 1; }
}

/* v2.0.230 — watered indicator uses the pixel-art water_wave.png (same
 * sprite used for the watering action icon). Previously 💧 emoji. */
.mg-farm-cell.is-watered::after {
    content: "";
    position: absolute;
    bottom: 2px; left: 2px;
    width: 14px; height: 16px;
    background-image: url("assets/ui/emoji/water_wave.png");
    background-size: contain;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    opacity: 0.85;
}

.mg-farm-cell-timer {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    /* v2.0.35: warm wood-brown ribbon (was flat black) to match the
     * pixel-wood UI theme; cream text keeps contrast on the brown. */
    background: rgba(74, 51, 24, 0.82);
    color: #f7ecd5;
    font-size: 0.75rem;
    text-align: center;
    line-height: 1.2;
    padding: 2px 0;
    font-variant-numeric: tabular-nums;
    image-rendering: auto;
}

/* ---------- Player character ----------
 *
 * v2.0.4: instead of one spritesheet + background-position to pick
 * the frame, each frame is its own 48×48 PNG file
 * (characters/avatar_<dir>_<col>.png, dir in down/up/left/right,
 * col 0..3 = walk cycle). JS swaps background-image directly via
 * updatePlayerSprite() — no offset math, no sheet leakage.
 *
 * Background-size: 100% 100% scales the 48-source frame to fill
 * the 96-display cell (2× scale, integer, crisp).
 */

.mg-farm-player {
    --x: 9;
    --y: 10;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    /* background-image set by JS updatePlayerSprite() */
    z-index: 10;
    transition: left 0.18s linear, top 0.18s linear;
    pointer-events: none;
}

/* ---------- Day/Night (applied to viewport so it tints everything) ---------- */

/* v2.0.179 — Filter moved from .mg-farm-viewport-outer to .mg-farm-viewport
 * so the new .mg-farm-scene-lights layer (sibling of viewport at z=1000)
 * can stay at full brightness. The viewport is the SCENE container — it
 * gets dimmed at night; lights are emitted ON TOP and cut through. */
.mg-farm-viewport-outer.is-day      .mg-farm-viewport { filter: none; }
.mg-farm-viewport-outer.is-dusk     .mg-farm-viewport { filter: brightness(0.95) saturate(1.05); }
.mg-farm-viewport-outer.is-night    .mg-farm-viewport { filter: brightness(0.85) saturate(0.95); }
.mg-farm-viewport-outer.is-dawn     .mg-farm-viewport { filter: brightness(0.97) saturate(1.0); }
.mg-farm-viewport { transition: filter 1.5s ease-in-out; }

/* v2.0.31: time-of-day TINT via a translucent overlay instead of
 * hue-rotate (which spun the green grass to an ugly purple at night).
 * The overlay sits above the whole scene (isolation:isolate makes the
 * outer a stacking context so the high z-index beats the player/chrome),
 * pointer-events:none so clicks pass through. */
.mg-farm-viewport-outer { isolation: isolate; }
.mg-farm-viewport-outer::after {
    content: ""; position: absolute; inset: 0; z-index: 900;
    pointer-events: none; opacity: 0;
    transition: opacity 1.5s ease-in-out, background-color 1.5s ease-in-out;
    background: transparent;
}
.mg-farm-viewport-outer.is-dusk::after  { background: rgba(255, 132, 52, 0.14); opacity: 1; }  /* warm sunset */
.mg-farm-viewport-outer.is-dawn::after  { background: rgba(255, 198, 120, 0.10); opacity: 1; } /* soft dawn */
.mg-farm-viewport-outer.is-night::after { background: rgba(26, 38, 92, 0.26); opacity: 1; }     /* moonlit blue */

/* ---------- Scene lights overlay (v2.0.179) ---------- */
/* Sibling of .mg-farm-viewport, ABOVE the night ::after tint (z=900).
 * Holds light-source pseudo-elements (campfire glow today, future:
 * lanterns, christmas-tree star). Two key behaviours:
 *   1. NOT inside .mg-farm-viewport → escapes the brightness filter,
 *      so the warm glow stays vivid even at night.
 *   2. Mirrors the viewport's responsive scale (--viewport-scale set by
 *      fitViewportToWidth) AND the scene's camera translate (--cam-x,
 *      --cam-y set by updateCamera) so its children stay locked to scene
 *      cells as the camera follows the player. Lights use the SAME
 *      .mg-farm-chrome positioning (--x/--y/--w/--h in cells). */
.mg-farm-scene-lights {
    position: absolute;
    top: 0;
    left: 0;
    width:  calc(var(--scene-cols) * var(--cell));
    height: calc(var(--scene-rows) * var(--cell));
    pointer-events: none;
    z-index: 1000;   /* > 900 night ::after, > anything in viewport */
    transform-origin: 0 0;
    transform: scale(var(--viewport-scale, 1)) translate(var(--cam-x, 0px), var(--cam-y, 0px));
    transition: transform 0.18s linear;
    /* v2.0.184 — override the inherited `image-rendering: pixelated`
     * from .mg-farm-viewport-outer. That setting is correct for the
     * pixel-art sprites in the scene, but some browsers also apply it
     * to CSS radial gradients, producing blocky stepped edges on the
     * glow's low-alpha outer ring (which read as a square boundary).
     * Auto/smooth rendering restores the continuous gradient. */
    image-rendering: auto;
}
.mg-farm-scene-lights > * {
    position: absolute;
    left: calc(var(--x, 0) * var(--cell));
    top:  calc(var(--y, 0) * var(--cell));
    width:  calc(var(--w, 1) * var(--cell));
    height: calc(var(--h, 1) * var(--cell));
    pointer-events: none;
}

/* v2.0.195 — Sakura petals layer. Mirrors scene-lights structure
 * (sibling of viewport, mirrors camera transform) but z-index 800,
 * BELOW the night ::after tint at z=900. Effect: petals get darkened
 * by night naturally — they're falling physical things, not glowing
 * light sources, so they should sit IN the scene rather than over it. */
.mg-farm-scene-petals {
    position: absolute;
    top: 0;
    left: 0;
    width:  calc(var(--scene-cols) * var(--cell));
    height: calc(var(--scene-rows) * var(--cell));
    pointer-events: none;
    z-index: 800;   /* < 900 night ::after — petals get dimmed at night */
    transform-origin: 0 0;
    transform: scale(var(--viewport-scale, 1)) translate(var(--cam-x, 0px), var(--cam-y, 0px));
    transition: transform 0.18s linear;
    image-rendering: auto;
}

/* Campfire glow — warm radial light that brightens surroundings,
 * dramatically at night, subtly in daylight. mix-blend-mode plus-lighter
 * = additive (per-channel sum), so it actually LIGHTS the scene rather
 * than just tinting it. Pseudo-element is 12 cells across (6-cell
 * radius). Centered slightly above cell-middle because the campfire
 * sprite is bottom-anchored — flame sits in the upper half.
 *
 * v2.0.182 — Two refinements after the v2.0.181 round felt unnatural:
 *   1. OUTER ALPHA BOOSTED. Mid/far stops (42% / 65% / 88%) were 0.14
 *      / 0.06 / 0.01 — at distance 4-5 cells from fire, plus-lighter
 *      added barely-visible warm tint to objects like the big snowman.
 *      Bumped to 0.22 / 0.13 / 0.04 — objects 4-5 cells out now read
 *      as clearly lit. Center alpha (0.55) kept so sprite shows through.
 *   2. FLICKER REWRITTEN. v2.0.181 used ease-in-out + 2.7s/1.9s periods
 *      = smooth breathing-UI feel, not fire. New design: LINEAR timing
 *      + much faster periods (0.83s/0.59s) + irregular non-monotonic
 *      keyframes = jagged jittery motion matching how flame light
 *      actually behaves. Compounded by the sprite ANIMATION (see
 *      DECOR_VARIANTS w_campfire.frames) on its own 130ms cycle — three
 *      independent unsynced periods.
 *
 * v2.0.184 — `radial-gradient(circle <explicit-radius> at center, ...)`.
 * Previously `radial-gradient(circle, ...)` defaulted to ending-shape
 * `farthest-corner` — for a square 12-cell box, the gradient circle
 * stretched to the corners (~8.49 cells), so the cardinal box edges
 * were at gradient-position 70.7% with alpha still ~0.10 visible. The
 * corners showed faint warm color, making the overall light footprint
 * look like a square outline rather than a circle. Locking the gradient
 * to an explicit 6-cell radius decouples it from the box — outside that
 * circle is fully transparent regardless of box shape. */
.mg-farm-light--w_campfire::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 40%;
    width:  calc(var(--cell) * 12);
    height: calc(var(--cell) * 12);
    transform: translate(-50%, -50%) scale(1);
    background: radial-gradient(circle calc(var(--cell) * 6) at center,
        rgba(255, 240, 180, 0.42)  0%,
        rgba(255, 220, 140, 0.38)  6%,
        rgba(255, 180,  90, 0.32) 14%,
        rgba(255, 140,  55, 0.24) 26%,
        rgba(255, 110,  35, 0.17) 42%,
        rgba(255,  90,  20, 0.10) 65%,
        rgba(255,  90,  20, 0.03) 88%,
        rgba(255,  90,  20, 0)   100%);
    mix-blend-mode: plus-lighter;
    opacity: 0;
    /* opacity transition for day-night fade, NOT animated by flicker
     * (flicker only touches transform + filter so the per-class opacity
     * stays authoritative). */
    transition: opacity 1.5s ease-in-out;
    animation:
        mg-farm-fire-scale      3.5s linear infinite,
        mg-farm-fire-brightness 2.6s linear infinite;
    will-change: transform, filter, opacity;
}

/* v2.0.185 — Slowed again (2.3s → 3.5s) per user. 16 irregular keyframes
 * spread over 3.5s means each leg is ~220ms — visible but unhurried.
 * Amplitude (0.92 ↔ 1.10) unchanged. */
@keyframes mg-farm-fire-scale {
    0%   { transform: translate(-50%, -50%) scale(1.00); }
    6%   { transform: translate(-50%, -50%) scale(1.06); }
    13%  { transform: translate(-50%, -50%) scale(0.94); }
    19%  { transform: translate(-50%, -50%) scale(1.03); }
    27%  { transform: translate(-50%, -50%) scale(0.97); }
    34%  { transform: translate(-50%, -50%) scale(1.09); }
    41%  { transform: translate(-50%, -50%) scale(0.92); }
    49%  { transform: translate(-50%, -50%) scale(1.04); }
    56%  { transform: translate(-50%, -50%) scale(0.96); }
    62%  { transform: translate(-50%, -50%) scale(1.07); }
    69%  { transform: translate(-50%, -50%) scale(0.93); }
    76%  { transform: translate(-50%, -50%) scale(1.05); }
    83%  { transform: translate(-50%, -50%) scale(0.98); }
    89%  { transform: translate(-50%, -50%) scale(1.08); }
    95%  { transform: translate(-50%, -50%) scale(0.95); }
    100% { transform: translate(-50%, -50%) scale(1.00); }
}

/* Brightness on its own slower (1.7s → 2.6s) co-prime period.
 * 14 keyframes, asymmetric (more bright peaks than dim troughs — real
 * fire spends more time bright than dark). LCM with scale (3.5s) is
 * 91s, plus the random-order sprite at 400ms = three layers that
 * never collectively repeat at perceptible scale. */
@keyframes mg-farm-fire-brightness {
    0%   { filter: brightness(1.00); }
    7%   { filter: brightness(1.10); }
    15%  { filter: brightness(0.90); }
    22%  { filter: brightness(1.14); }
    29%  { filter: brightness(0.95); }
    37%  { filter: brightness(1.08); }
    44%  { filter: brightness(0.86); }
    52%  { filter: brightness(1.16); }
    59%  { filter: brightness(0.93); }
    67%  { filter: brightness(1.11); }
    74%  { filter: brightness(0.97); }
    82%  { filter: brightness(1.06); }
    91%  { filter: brightness(0.89); }
    100% { filter: brightness(1.00); }
}

/* v2.0.194 — Sakura falling petals.
 *
 * Lives in the same .mg-farm-scene-lights layer the campfire glow uses
 * (already z=1000 above the night tint, pointer-events:none, escapes
 * the day/night brightness/saturate filter so colour stays true).
 * Petals are spawned by initSakuraPetals() in JS when the active layout
 * is sakura, removed on layout-swap-away.
 *
 * Each petal: 6px sprite scaled to about 1/4 cell, absolutely positioned
 * in scene coords (so it drifts WITH the world as camera scrolls — looks
 * like petals are physically in the air over the farm). Random `left`,
 * `animation-duration`, `animation-delay` (negative so they start
 * mid-cycle on first paint — no all-petals-aligned wave).
 *
 * Animation: vertical fall from above scene-top to past scene-bottom
 * (~120% of scene-height), with a sinusoidal horizontal sway via a
 * second keyframe + rotate for tumbling. Opacity fades in at start,
 * fades out at end so spawn/despawn isn't a hard pop.
 *
 * Performance: ~10 petals × 1 CSS animation (transform + opacity, both
 * GPU-composited) = ~10 GPU layer composites. Negligible on any device
 * built after 2018. */
.mg-farm-petal {
    position: absolute;
    top: 0;
    width: calc(var(--cell) * 0.28);
    height: calc(var(--cell) * 0.28);
    background-image: url("assets/objects/sakura/petal.png");
    background-size: contain;
    background-repeat: no-repeat;
    image-rendering: auto;   /* override pixelated inheritance — small sprite scales smoothly */
    opacity: 0;
    pointer-events: none;
    animation-name: mg-farm-petal-fall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    will-change: transform, opacity;
}

@keyframes mg-farm-petal-fall {
    0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
    8%   { opacity: 0.85; }
    25%  { transform: translate(calc(var(--cell) * 0.6), calc(var(--scene-rows) * var(--cell) * 0.25)) rotate(90deg); }
    50%  { transform: translate(calc(var(--cell) * -0.4), calc(var(--scene-rows) * var(--cell) * 0.50)) rotate(180deg); }
    75%  { transform: translate(calc(var(--cell) * 0.7), calc(var(--scene-rows) * var(--cell) * 0.75)) rotate(270deg); }
    92%  { opacity: 0.7; }
    100% { transform: translate(calc(var(--cell) * -0.3), calc(var(--scene-rows) * var(--cell) * 1.1)) rotate(360deg); opacity: 0; }
}

/* v2.0.195 added a CSS rotate-sway on sakura trees/bushes as a workaround
 * because the biome's no-fruit pink tree had no 4-frame anim. v2.0.196
 * replaced those sprites with HSV-tinted meadow trees (which DO have
 * proper 4-frame sway anim + visible fruit), so the CSS sway was
 * removed — the native frame-swap animation now handles motion the same
 * way meadow + winter do. Comment kept as a reminder of why the rule
 * is intentionally absent. */

/* Intensity by time of day — day is barely a hint (sun overpowers),
 * night is full punch. The radius shrinks visually at low opacity
 * because the outermost stops already fade to transparent. */
.mg-farm-viewport-outer.is-day   .mg-farm-light--w_campfire::after { opacity: 0.18; }
.mg-farm-viewport-outer.is-dusk  .mg-farm-light--w_campfire::after { opacity: 0.55; }
.mg-farm-viewport-outer.is-dawn  .mg-farm-light--w_campfire::after { opacity: 0.45; }
.mg-farm-viewport-outer.is-night .mg-farm-light--w_campfire::after { opacity: 0.95; }

/* Respect reduced-motion — kill the flicker, keep the static glow. */
@media (prefers-reduced-motion: reduce) {
    .mg-farm-light--w_campfire::after { animation: none; }
}

/* ---------- Sidebar ---------- */

.mg-farm-main {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.mg-farm-sidebar {
    flex: 1 1 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mg-farm-action-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-warm);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    min-height: 56px;
}
.mg-farm-hint { color: var(--text-muted); font-size: 0.9rem; margin: 0; }
/* v2.0.295 — keyboard-controls hint: smaller + more muted than the main
 * tap hint so it reads as a secondary aside, with a little top gap. */
.mg-farm-hint--keys {
    font-size: 0.78rem;
    opacity: 0.75;
    margin-top: 0.35rem;
}
.mg-farm-action-cell-label { font-weight: 600; margin: 0 0 0.35rem; }
.mg-farm-action-buttons { display: flex; flex-wrap: wrap; gap: 0.3rem; }
/* v2.0.145 — buttons inside action panel are equal-width by default
 * (prevents wider content like "收 鮮奶（可賣 900）" from out-stretching
 * its sibling like the "Lv 2 啡色" upgrade button). min-width: 0 lets
 * text wrap within the equal slot rather than overflow. Mobile media
 * query just adds min-height for tap-target friendliness. */
.mg-farm-action-buttons .mg-farm-btn { flex: 1 1 0; min-width: 0; }
/* v2.0.146 — true pixel-art up arrow (replaces v2.0.145 CSS triangle).
 * 7×7 SVG grid with shape-rendering: crispEdges → each SVG-pixel renders
 * as a perfectly square block at 2× scale (14×14 display). mask-image +
 * currentColor preserves "follows text colour" so it matches the button
 * label tint without hardcoding. Grid layout:
 *
 *   . . . X . . .     ← tip (1 px)
 *   . . X X X . .
 *   . X X X X X .     ← arrow base (wide)
 *   . . . X . . .     ← stem
 *   . . . X . . .
 *   . . . X . . .
 *   . . . X . . .
 */
.mg-farm-ic-up {
    display: inline-block;
    width: 14px; height: 14px;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='black'><rect x='3' y='0' width='1' height='1'/><rect x='2' y='1' width='3' height='1'/><rect x='1' y='2' width='5' height='1'/><rect x='3' y='3' width='1' height='4'/></svg>") center / contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='black'><rect x='3' y='0' width='1' height='1'/><rect x='2' y='1' width='3' height='1'/><rect x='1' y='2' width='5' height='1'/><rect x='3' y='3' width='1' height='4'/></svg>") center / contain no-repeat;
    vertical-align: middle;
    margin-right: 5px;
}

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

.mg-farm-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    /* v2.0.94 — explicit wrap-friendly defaults so the cow/chicken
       upgrade button (which carries Lv + tier + cost + cycle in one
       label, often using <br>) sits inside its panel on narrow
       mobile screens instead of overflowing horizontally. */
    white-space: normal;
    word-break: keep-all;
    text-align: center;
    transition: background 0.12s;
}
.mg-farm-btn:hover { background: var(--accent-dark); }
.mg-farm-btn:disabled { background: #b5b5b5; cursor: not-allowed; opacity: 0.7; }
.mg-farm-btn:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; }
.mg-farm-btn-secondary {
    background: var(--bg-card); color: var(--text); border: 1px solid var(--border-warm);
}
.mg-farm-btn-secondary:hover { background: rgba(0, 0, 0, 0.04); }

.mg-farm-shop-buttons { display: flex; gap: 0.35rem; }
.mg-farm-btn-shop {
    flex: 1; font-size: 0.85rem; padding: 0.55rem 0.4rem;
}

/* ---------- Inventory ---------- */

.mg-farm-section-title {
    font-size: 0.95rem;
    margin: 0 0 0.4rem;
    color: var(--text-muted);
    font-weight: 600;
}
.mg-farm-inventory {
    background: var(--bg-card);
    border: 1px solid var(--border-warm);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
}
.mg-farm-inv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.mg-farm-inv-item {
    background: var(--bg-soft);
    border: 1px solid var(--border-warm);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.85rem;
    white-space: nowrap;
}
.mg-farm-inv-item-qty { color: var(--text-muted); font-variant-numeric: tabular-nums; margin-left: 0.25rem; }
.mg-farm-inv-empty { color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Modal ---------- */

.mg-farm-modal {
    /* v2.0.75 — modal is reparented to <body> at init, so it no
     * longer inherits the .mg-farm-root CSS variable scope. Redeclare
     * the tokens the modal CSS uses (palette + cell-size). Keep in
     * sync with the .mg-farm-root block above. */
    --cell: 96px;
    --bg-root: #8b6f47;
    --bg-deep: #a5855c;
    --bg-soft: #f2e6c8;
    --bg-card: #ffffff;
    --border-warm: #5c4222;
    --border-soft: #a8835c;
    --accent: #6b8e23;
    --accent-dark: #4a6818;
    --text: #2b2014;
    --text-on-dark: #fff4d4;
    --text-muted: #6b5536;
    --text-muted-on-dark: #d9c294;
    font-family: "Cubic 11", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK TC", sans-serif;
    color: var(--text);
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.mg-farm-modal[hidden] { display: none; }
.mg-farm-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
.mg-farm-modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.1rem;
    max-width: 520px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}
.mg-farm-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border-warm);
    padding-bottom: 0.4rem; margin-bottom: 0.8rem;
}
.mg-farm-modal-title { font-size: 1.1rem; margin: 0; }
.mg-farm-modal-close-x {
    background: none; border: none; line-height: 1;
    cursor: pointer; padding: 0 0.25rem;
}
/* v2.0.75 — inner mg-ic centred in the wood button */
.mg-farm-modal-close-x .mg-ic {
    width: 16px; height: 16px;
    margin: 0;
    vertical-align: middle;
}

.mg-farm-shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
}
.mg-farm-shop-card {
    border: 1px solid var(--border-warm);
    border-radius: 6px;
    padding: 0.5rem;
    background: var(--bg-soft);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    align-items: center;
    text-align: center;
}
.mg-farm-shop-card-sprite {
    width: 48px; height: 48px;
    background-repeat: no-repeat;
    image-rendering: pixelated;
}
.mg-farm-shop-card-name { font-weight: 600; font-size: 0.85rem; }
.mg-farm-shop-card-price { color: var(--text-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.mg-farm-shop-card-meta { color: var(--text-muted); font-size: 0.74rem; }
.mg-farm-shop-qty {
    width: 60px;
    text-align: center;
    /* v2.0.41 — visible "border" now drawn via inset box-shadow instead
     * of `border`. Site themes routinely add `input { border-color: ...
     * !important }` or `input:focus { outline: ... !important }` that
     * paint OVER our actual border / outline. They almost never touch
     * box-shadow on inputs — so we set border:0 + outline:0 + use an
     * inset shadow for the visual frame. The site theme's red focus
     * ring (image 1 screenshot) survived 2.0.39's specificity bump
     * via `!important` injection in a `<style>` block their plugin
     * stitches into <head> after our stylesheet. This bypasses that.
     */
    border: 0 !important;
    border-radius: 3px;
    padding: 0.2rem;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    /* v2.0.32: was inheriting a near-invisible light colour. Force dark,
     * high-contrast text (text-fill-color too, for mobile WebKit). */
    color: #3a3329;
    -webkit-text-fill-color: #3a3329;
    background: #fffdf5;
    outline: 0 !important;
    box-shadow: inset 0 0 0 2px var(--border-warm);
}
.mg-farm-root .mg-farm-shop-qty:focus,
.mg-farm-root .mg-farm-shop-qty:focus-visible {
    border: 0 !important;
    outline: 0 !important;
    background: #fffdf5 !important;
    color: #3a3329 !important;
    -webkit-text-fill-color: #3a3329 !important;
    /* Two-stop shadow: inner border + outer halo (the "focus ring"). */
    box-shadow: inset 0 0 0 2px var(--accent-dark),
                0 0 0 2px rgba(74, 104, 24, 0.35) !important;
}

/* ---------- v2.0.36 — Locked seed cards in shop ---------- */
/* Greyed silhouette + progress bar; player sees what to chase. */
/* v2.0.38 — gradient deepened (was #efe7d7 → #e2d7c2 pale cream) so
 * locked cards still register as "muted" on the honey wood panel
 * background. Stays warm-toned so it doesn't fight the theme. */
.mg-farm-shop-card.is-locked {
    background: linear-gradient(135deg, #b59872 0%, #8a7150 100%);
    color: #f5e8c8;
    opacity: 0.95;
    position: relative;
    overflow: hidden;
}
.mg-farm-shop-card.is-locked .mg-farm-shop-card-name {
    color: #f5e8c8;
}
.mg-farm-shop-card.is-locked .mg-farm-shop-card-price {
    color: #ffe0a8;
    font-weight: 600;
}
.mg-farm-shop-card.is-locked .mg-farm-shop-card-meta {
    color: #e5d2a8;
    font-size: 0.72rem;
    line-height: 1.2;
}
.mg-farm-locked-sprite {
    position: relative;
    width: 48px; height: 48px;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    /* Desaturate + darken the seed-packet sprite so it reads as
     * "locked silhouette" without needing a separate asset. */
    filter: grayscale(1) brightness(0.6) contrast(0.9);
}
.mg-farm-locked-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    filter: none;       /* override parent's grayscale on the lock icon */
}
/* v2.0.79 — explicit lock size in the shop-card overlay. Without this
 * the .mg-ic inherits the card's font-size, which is small (~0.8rem),
 * making the padlock unreadable; or with .lg added it ballooned to
 * 2em (2.6rem) and overflowed. Pin to a concrete pixel value tuned
 * for the card size. */
.mg-farm-locked-overlay .mg-ic {
    width: 28px;
    height: 28px;
    margin: 0;
}
.mg-farm-locked-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.15rem;
}
.mg-farm-locked-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #d4a847 0%, #f0c563 100%);
    transition: width 200ms ease-out;
}

/* ---------- v2.0.36 — Sell-to-merchant tab ---------- */
.mg-farm-sell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.mg-farm-sell-header .mg-farm-hint { margin: 0; }
.mg-farm-sell-stock {
    color: #8a6320;   /* v2.0.70 — amber, was moss green */
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.mg-farm-sell-btn-row {
    display: flex;
    flex-wrap: wrap;          /* v2.0.40 — wrap on narrow shop cards */
    gap: 0.3rem;
    width: 100%;
    margin-top: 0.2rem;
}
.mg-farm-sell-btn-row .mg-farm-btn {
    /* v2.0.40 — sell card buttons on mobile.
     *
     * Pre-2.0.40 was `flex: 1` (one-third syntax: shrink, grow, basis=0%).
     * On a 130px shop-grid card the two buttons split ≈54px each after the
     * 0.3rem gap, and "賣全部 (30)" at 0.78rem inside a wood-skin border
     * (12px of border-image padding) does not fit — text was bleeding out
     * the LEFT of the card (see the carrot card overflow screenshot).
     *
     * Fix:
     *   - `min-width: 0` lets the flex item shrink past its intrinsic
     *     content width. Without this, the button width is locked to the
     *     content "賣全部 (30)" + 12px border, and the parent overflows.
     *   - `flex: 1 1 60px` keeps both buttons growing equally, but the
     *     60px basis triggers `flex-wrap: wrap` on the parent when the
     *     two basises + gap exceed the container — buttons stack
     *     vertically instead of clipping out the side. */
    flex: 1 1 60px;
    min-width: 0;
    padding: 0.35rem 0.4rem;
    font-size: 0.78rem;
    /* Truncate insurance — if the label is still oversized, ellipsis
     * inside the button rather than overflowing the card. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mg-farm-rename-form { display: flex; flex-direction: column; gap: 0.7rem; }
.mg-farm-rename-input {
    /* v2.0.41 — see .mg-farm-shop-qty for rationale. Border drawn via
     * inset box-shadow so the site theme's `input:focus { border-color:
     * red !important }` (the actual culprit in the rename-modal red
     * frame screenshot) can't override our visual. */
    width: 100%; padding: 0.5rem;
    border: 0 !important;
    border-radius: 4px; font-size: 1rem;
    color: #3a3329;
    -webkit-text-fill-color: #3a3329;
    background: #fffdf5;
    outline: 0 !important;
    box-shadow: inset 0 0 0 2px var(--border-warm);
}
.mg-farm-root .mg-farm-rename-input:focus,
.mg-farm-root .mg-farm-rename-input:focus-visible {
    border: 0 !important;
    outline: 0 !important;
    background: #fffdf5 !important;
    color: #3a3329 !important;
    -webkit-text-fill-color: #3a3329 !important;
    box-shadow: inset 0 0 0 2px var(--accent-dark),
                0 0 0 2px rgba(74, 104, 24, 0.35) !important;
}
.mg-farm-rename-help { font-size: 0.78rem; color: var(--text-muted); }

/* ---------- Toasts ----------
 *
 * v2.0.42 — wood-tone overrides for the cross-game .mg-toast classes
 * when the farm page is mounted.
 *
 * Background:
 *   v2.0.39 delegated farm toasts to window.MG.toast() so they share the
 *   arcade-wide top-center position + Cubic 11 font. That worked, but
 *   pulled in core's iOS palette (--mg-red: #ff453a, --mg-green: #30d158)
 *   which is SATURATED and SCREAMS "system alert" on the warm walnut
 *   wood theme. User feedback: "Toast的紅綠太誇張了，不配合現在的theme".
 *
 * Fix:
 *   Scope an override to body:has(.mg-farm-root) — present only while the
 *   farm shortcode is on the page — and override the .mg-toast--error /
 *   --success / --warning rules with earthy variants: brick-red,
 *   moss-green, honey-amber on a deep-walnut background. Other games on
 *   the same site keep the original iOS palette because the :has()
 *   scope doesn't match when no farm root is in the DOM.
 *
 *   :has() has full browser support across modern Chromium / WebKit /
 *   Firefox (since late 2023). If a player on a legacy browser hits
 *   the page, the rule simply doesn't apply and they get the default
 *   iOS palette — still readable, just not theme-matched. Graceful
 *   degradation.
 *
 *   The .mg-toast-container itself sits as a sibling of .mg-farm-root
 *   under <body>, NOT a descendant — so a regular `.mg-farm-root .mg-toast`
 *   selector wouldn't reach it. `body:has(.mg-farm-root) .mg-toast--error`
 *   threads the needle: match a body that contains a farm root, then
 *   find any .mg-toast--error descendant (which the toast container is).
 *
 * Legacy fallback:
 *   The farm.js toast() function falls back to a farm-local DOM stack
 *   if window.MG.toast isn't defined (shouldn't happen — mg-core is a
 *   declared dep of farm.js — but defensive). The .mg-farm-toast styles
 *   below cover that path with the same wood palette so the visual
 *   stays consistent across both code paths.
 * --------------------------------------------------------------------- */

/* ---- Wood-panel toasts (v2.0.63)
 *
 * Earlier passes (v2.0.42, v2.0.46) shifted toast colours toward
 * muted earth tones, but the underlying shape was still a flat dark
 * rectangle — clashed with the rest of the farm UI which uses the
 * panel.png 9-slice wood frame. v2.0.63 unifies: every toast now wears
 * the same wood skin.
 *
 * v2.0.71 — DROP coloured left-edge pip entirely. Player feedback:
 *   - Green pip looked off-theme even after the v2.0.70 olive shift
 *   - Emoji prefix in the message body (✓ 🎁 🥾 🌾 etc.) already
 *     carries the semantic signal, the pip was redundant.
 *   - Smaller toast + tighter padding lets it sit at top-center
 *     without dominating the viewport on mobile.
 *   - Force "Cubic 11" arcade font explicitly: toast container is a
 *     <body> sibling, not a .mg-farm-root descendant, so the global
 *     farm font-family wasn't inheriting.
 * ---- */
body:has(.mg-farm-root) .mg-toast {
    background: #f2e6c8;       /* honey wood interior */
    color: #2b2014;            /* dark walnut text */
    border: 10px solid transparent;
    border-image: url("assets/ui/panel.png") 14 fill / 10px / 0 stretch;
    image-rendering: pixelated;
    padding: 0.45rem 0.85rem;
    font-family: "Cubic 11", "Noto Sans CJK TC", sans-serif !important;
    /* v2.0.72 — font size REMOVED (was 0.82rem !important). Player
       feedback: should match other games' toast size. Cubic 11 inherits
       from MG core's --mg-body sizing now. */
    line-height: 1.4 !important;
    white-space: pre-line;     /* honour \n in toast text */
    box-shadow: 0 5px 12px rgba(60, 36, 20, 0.28);
    position: relative;
    overflow: hidden;
    max-width: 320px;
}
body:has(.mg-farm-root) .mg-toast > * { image-rendering: auto; font-family: inherit !important; }

/* v2.0.71 — the four .mg-toast--* variants no longer get a coloured
 * pip. The wood skin is the only background; semantics come from the
 * emoji at the start of the message text.
 * v2.0.72 — also explicitly kill any border-left / ::before pip that
 * MG-core or other game CSS may inject; the farm wood frame is the
 * complete look, no extra accent. */
body:has(.mg-farm-root) .mg-toast--error,
body:has(.mg-farm-root) .mg-toast--success,
body:has(.mg-farm-root) .mg-toast--warning,
body:has(.mg-farm-root) .mg-toast--info {
    background: #f2e6c8;
    color: #2b2014;
    border-left-width: 10px !important;   /* match the wood border */
    border-left-color: transparent !important;
}
body:has(.mg-farm-root) .mg-toast--success::before,
body:has(.mg-farm-root) .mg-toast--error::before,
body:has(.mg-farm-root) .mg-toast--warning::before,
body:has(.mg-farm-root) .mg-toast--info::before {
    content: none !important;
    background: transparent !important;
    width: 0 !important;
    display: none !important;
}

/* ---- Legacy farm-local fallback (used only if window.MG.toast is
       absent — shouldn't normally fire). Same wood skin so the look
       stays consistent. ---- */
.mg-farm-toast-stack {
    position: fixed;
    bottom: 1rem; right: 1rem;
    z-index: 10000;
    display: flex; flex-direction: column;
    gap: 0.4rem;
    pointer-events: none;
}
.mg-farm-toast {
    background: #f2e6c8;
    color: #2b2014;
    border: 10px solid transparent;
    border-image: url("assets/ui/panel.png") 14 fill / 10px / 0 stretch;
    image-rendering: pixelated;
    padding: 0.45rem 0.85rem;
    font-family: "Cubic 11", "Noto Sans CJK TC", sans-serif;
    line-height: 1.4;
    white-space: pre-line;
    max-width: 320px;
    box-shadow: 0 5px 12px rgba(60, 36, 20, 0.28);
    pointer-events: auto;
    animation: mg-farm-toast-in 0.2s ease-out;
    position: relative;
    overflow: hidden;
}
.mg-farm-toast > * { image-rendering: auto; }
.mg-farm-toast::before { content: none !important; display: none !important; }
.mg-farm-toast.is-error,
.mg-farm-toast.is-success,
.mg-farm-toast.is-warning,
.mg-farm-toast.is-info {
    background: #f2e6c8;
    color: #2b2014;
    border-left-color: transparent !important;
}
@keyframes mg-farm-toast-in {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

/* ---- v2.0.63 — Ready bubbles for tree fruit + animal products ----
 * Small wood-framed circle floating above any slot that's harvestable.
 * Same 9-slice border-image as the rest of the UI so it reads as
 * "in-world signage". A subtle bob animation draws the eye without
 * being annoying.
 *
 * The bubble itself is non-interactive (pointer-events: none) — the
 * player still clicks the slot beneath to collect.
 *
 * Position: --x / --y / --w / --h (cell coords) inherited from the
 * generic .mg-farm-chrome positioning system. We size the bubble
 * smaller than 1 cell and centre it horizontally + lift slightly so
 * it floats above the slot rather than overlapping its body.
 */
.mg-farm-ready-bubble {
    position: absolute;
    left: calc(var(--x, 0) * var(--cell));
    top:  calc(var(--y, 0) * var(--cell));
    width:  var(--cell);
    height: var(--cell);
    pointer-events: none;
    z-index: 220;
    display: flex;
    align-items: center;
    justify-content: center;
    /* v2.0.73 — lift HALF a cell (was -100%). With the full-cell lift
       the bubble floated a whole row above the sprite, which on a 2-
       cell-tall sprite (cow) opened a huge visual gap between the
       bubble and the cow's head. Half-lift hugs the sprite top. */
    transform: translateY(-50%);
}
/* v2.0.70 — `.is-2wide` modifier: when the source is a 2-cell-wide
 * sprite (fruit tree canopy or cow), expand bubble container to 2
 * cells wide so flex-centring lands the emoji over the centre of
 * the sprite instead of the left edge. */
.mg-farm-ready-bubble.is-2wide {
    width: calc(var(--cell) * 2);
}
.mg-farm-ready-bubble-inner {
    position: relative;
    /* v2.0.73 — fixed sizing relative to ONE cell, not the outer
       container. Previously `width: 62%` meant inner was 62% of
       outer; for 2-wide trees/cow that was 1.24 cells (huge), for
       1-wide chickens that was 0.62 cells (tiny). All bubbles now
       same size regardless of source-sprite width. */
    width:  calc(var(--cell) * 0.6);
    height: calc(var(--cell) * 0.6);
    background: #f4e4c4;
    border: 2px solid #6b4a2a;
    border-radius: 50%;
    box-shadow: 0 2px 0 rgba(60, 36, 20, 0.4),
                inset 0 1px 2px rgba(255, 255, 255, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell) * 0.4);
    line-height: 1;
    animation: mg-farm-ready-bob 1.8s ease-in-out infinite;
}
/* v2.0.75 — bubble's ic icon centred in the circle, no side margin */
.mg-farm-ready-bubble-inner .mg-ic {
    margin: 0;
    vertical-align: middle;
    width: 1.1em;
    height: 1.1em;
}
@keyframes mg-farm-ready-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-14%); }
}

/* ---- v2.0.63 — Ripe sparkle on harvestable plot cells (.is-ripe::before)
 * already exists earlier in this stylesheet (the ✨ corner star). We
 * intentionally do NOT add a second sparkle here; the existing rule is
 * sufficient + adding a second would override its content. The ready-
 * bubble overhead pip handles the "you can do something here" cue for
 * trees + animals where there's no cell-level sparkle.
 */

/* ---------- Logged-out ---------- */

.mg-farm-loggedout {
    max-width: 480px; margin: 2rem auto; padding: 2rem;
    text-align: center;
    color: var(--text-on-dark);
    background: var(--bg-root);
    border: 2px solid var(--border-warm);
    border-radius: 12px;
}
.mg-farm-login-btn {
    display: inline-block; padding: 0.5rem 1rem;
    background: #6b8e23; color: #fff !important;
    text-decoration: none; border-radius: 5px;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .mg-farm-scene,
    .mg-farm-cell,
    .mg-farm-player,
    .mg-farm-cell.is-ripe::before,
    .mg-farm-toast,
    .mg-farm-viewport,
    .mg-farm-viewport-outer,
    .mg-farm-scene-lights {
        transition: none !important;
        animation: none !important;
    }
}

/* =======================================================================
 * v2.0.23 — Pixel UI skin (Sprout Lands UI Pack)
 *
 * Closes the "靚世界、普通 UI" gap: the farm world is pixel-art but the
 * surrounding chrome (panels, buttons, modal, inventory) was plain CSS.
 * This layer skins them with the UI pack's wood sprites.
 *
 * Performance-first ("效能為上"):
 *   - 100% CSS border-image / background — NO extra DOM, NO per-frame JS,
 *     GPU-composited. Sprites are <1 KB each.
 *   - Uniform-edge 9-slices (panel/button/slot) stretch crisply; the
 *     `fill` keyword paints the centre so no inner element is needed.
 *   - image-rendering: pixelated keeps the art crisp when the frame
 *     stretches to fit text/content.
 *   - Layered as overrides AFTER the base rules so layout, padding,
 *     :focus-visible, :disabled and all i18n text are preserved.
 *
 * Reusable components (also used by the fishing catch popup / fish-dex):
 *   .mg-farm-panel-skin   wood 9-slice frame (panel.png)
 *   .mg-farm-btn          wood button + pressed state (btn / btn_active)
 *   .mg-farm-inv-item     wood inventory slot chip (slot.png)
 *   .mg-farm-bubble       wood speech bubble w/ tail (bubble.png)
 * ===================================================================== */

/* ---- Wood 9-slice panel (action panel, inventory, modal) ---- */
.mg-farm-action-panel,
.mg-farm-inventory,
.mg-farm-panel-skin {
    background: none;
    border: 14px solid transparent;
    border-image: url("assets/ui/panel.png") 14 fill / 14px / 0 stretch;
    border-radius: 0;
    image-rendering: pixelated;
}
/* keep inner text smoothly rendered, not pixelated */
.mg-farm-action-panel > *,
.mg-farm-inventory > *,
.mg-farm-panel-skin > * { image-rendering: auto; }

.mg-farm-modal-content {
    background: none;
    border: 20px solid transparent;
    border-image: url("assets/ui/panel.png") 14 fill / 20px / 0 stretch;
    border-radius: 0;
    padding: 0.4rem 0.9rem 0.9rem;
    image-rendering: pixelated;
    /* keep the depth shadow under the wood frame */
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.28));
    box-shadow: none;
}
.mg-farm-modal-content > * { image-rendering: auto; }
.mg-farm-modal-header { border-bottom-color: rgba(120, 86, 45, 0.35); }

/* ---- v2.0.133 — wood-frame depth + corner pegs ----
 *
 * Structural, not decorative: instead of a motif sitting on the wood
 * (the rejected garland), give the plank itself dimensionality.
 *   - DEPTH: an inset top highlight + bottom shadow so each panel reads
 *     as a thick, slightly-lit board rather than a flat honey slab.
 *     Lives on the element's box-shadow, so it never scrolls or shifts.
 *   - PEGS: four small "iron rivets" (radial-gradient, domed highlight)
 *     tucked into the inner corners via a single ::after with four
 *     background layers (one pseudo-element → four pegs). inset:0 keeps
 *     them inside the padding box so the modal's overflow-y:auto can't
 *     clip them. pointer-events:none → never blocks a tap.
 * No change to the 9-slice border-image itself. */
.mg-farm-action-panel,
.mg-farm-inventory,
.mg-farm-panel-skin { position: relative; }

.mg-farm-action-panel,
.mg-farm-inventory,
.mg-farm-panel-skin,
.mg-farm-modal-content {
    box-shadow:
        inset 0 2px 0 rgba(255, 248, 230, 0.20),
        inset 0 -5px 6px rgba(74, 49, 32, 0.30);
}

.mg-farm-action-panel::after,
.mg-farm-inventory::after,
.mg-farm-panel-skin::after,
.mg-farm-modal-content::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    image-rendering: auto;
    background-repeat: no-repeat;
    background-image:
        radial-gradient(circle at 40% 35%, #6e4d30 0%, #4a3120 58%, rgba(74, 49, 32, 0) 64%),
        radial-gradient(circle at 40% 35%, #6e4d30 0%, #4a3120 58%, rgba(74, 49, 32, 0) 64%),
        radial-gradient(circle at 40% 35%, #6e4d30 0%, #4a3120 58%, rgba(74, 49, 32, 0) 64%),
        radial-gradient(circle at 40% 35%, #6e4d30 0%, #4a3120 58%, rgba(74, 49, 32, 0) 64%);
    background-size: 7px 7px;
    background-position:
        3px 3px,
        calc(100% - 3px) 3px,
        3px calc(100% - 3px),
        calc(100% - 3px) calc(100% - 3px);
}

/* ---- Wood buttons (raised + pressed) ----
 *
 * v2.0.42 — added !important on the visual properties (background,
 * border, border-image, outline, box-shadow, color) so site themes
 * that inject `button:hover { background: red !important; border: 2px
 * solid red !important }` can't paint over the 9-slice. The
 * border-image fully covers the transparent solid `border`, and the
 * `background: none` keeps the slice's pixels showing — but a site
 * theme background paint would have appeared *behind* the transparent
 * border-image bevel and bled through the rounded corners. Same
 * lockdown pattern as .mg-farm-rename-btn.
 *
 * Note: filter:brightness is the hover affordance instead of a colour
 * change, so a hostile site theme has no easy attack surface on a
 * non-paint property. */
.mg-farm-btn {
    background: none !important;
    color: #5b3a16 !important;
    -webkit-text-fill-color: #5b3a16;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.30);
    border: 6px solid transparent !important;
    border-width: 6px 6px 8px 6px !important;          /* extra bottom = the bevel */
    border-image: url("assets/ui/btn.png") 6 6 8 6 fill / 6px 6px 8px 6px / 0 stretch !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: 0 !important;
    padding: 0.3rem 0.7rem;
    image-rendering: pixelated;
    transition: filter 0.1s;
}
.mg-farm-root .mg-farm-btn:hover {
    background: none !important;
    border-image: url("assets/ui/btn.png") 6 6 8 6 fill / 6px 6px 8px 6px / 0 stretch !important;
    color: #5b3a16 !important;
    -webkit-text-fill-color: #5b3a16;
    box-shadow: none !important;
    outline: 0 !important;
    filter: brightness(1.05);
}
.mg-farm-root .mg-farm-btn:active {
    border-width: 6px !important;                       /* lose the bottom bevel */
    border-image: url("assets/ui/btn_active.png") 6 fill / 6px / 0 stretch !important;
    background: none !important;
    color: #5b3a16 !important;
    -webkit-text-fill-color: #5b3a16;
    box-shadow: none !important;
    outline: 0 !important;
    transform: translateY(1px);
}
.mg-farm-btn:disabled {
    background: none !important;
    filter: grayscale(0.7) brightness(1.08);
    opacity: 0.65;
}
.mg-farm-root .mg-farm-btn:focus-visible {
    outline: 3px solid var(--accent-dark) !important;
    outline-offset: 1px;
    box-shadow: none !important;
}
/* secondary keeps the same wood skin (override the plain-CSS look) */
.mg-farm-btn-secondary { background: none !important; color: #5b3a16 !important; -webkit-text-fill-color: #5b3a16; }
.mg-farm-root .mg-farm-btn-secondary:hover { background: none !important; filter: brightness(1.05); }

/* v2.0.65 — disabled-look button (still clickable, but visually says
 * "you can't afford this"). Used for the cow upgrade button when the
 * player's coins are below the next-tier cost. Clicking shows a toast
 * instead of firing the API call, so the click handler stays attached.
 */
.mg-farm-btn-disabled {
    background: none !important;
    color: #8a7355 !important;
    -webkit-text-fill-color: #8a7355;
    opacity: 0.65;
    cursor: not-allowed;
}
.mg-farm-root .mg-farm-btn-disabled:hover { filter: none; opacity: 0.75; }

/* ---- Inventory slots (wood chips) ---- */
.mg-farm-inv-list { gap: 0.35rem; }
.mg-farm-inv-item {
    background: none;
    border: 8px solid transparent;
    border-image: url("assets/ui/slot.png") 12 fill / 8px / 0 stretch;
    border-radius: 0;
    padding: 0.15rem 0.45rem;
    color: #4a3318;
    image-rendering: pixelated;
}
.mg-farm-inv-item > * { image-rendering: auto; }
.mg-farm-inv-item-qty { color: #7a5a30; }

/* ---- Modal close: wood button with the pack's pixel close icon ----
 * v2.0.42 — hardened against site-theme button overrides.
 * v2.0.75 — icon is now an <span class="mg-ic mg-ic-close"> child,
 * not a "×" text glyph. The CSS positions the wood frame; the icon
 * span lives inside it. */
.mg-farm-modal-close-x {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border: 6px solid transparent !important;
    border-width: 6px 6px 8px 6px !important;
    border-image: url("assets/ui/btn.png") 6 6 8 6 fill / 6px 6px 8px 6px / 0 stretch !important;
    border-radius: 0 !important;
    background: none !important;
    box-shadow: none !important;
    outline: 0 !important;
    image-rendering: pixelated;
    padding: 0;
    transition: filter 0.1s;
    cursor: pointer;
}
/* v2.0.75 — these were `.mg-farm-root .mg-farm-modal-close-x` but
 * the modal is reparented to <body> at init(); drop the prefix so
 * the rules still match. Specificity stays close enough because
 * `.mg-farm-modal-close-x` is a single dedicated class. */
.mg-farm-modal-close-x:hover {
    background: none !important;
    border-image: url("assets/ui/btn.png") 6 6 8 6 fill / 6px 6px 8px 6px / 0 stretch !important;
    box-shadow: none !important;
    outline: 0 !important;
    filter: brightness(1.05);
}
.mg-farm-modal-close-x:active {
    border-width: 6px !important;
    border-image: url("assets/ui/btn_active.png") 6 fill / 6px / 0 stretch !important;
    background: none !important;
    box-shadow: none !important;
    outline: 0 !important;
    transform: translateY(1px);
}
.mg-farm-modal-close-x:focus-visible {
    outline: 3px solid var(--accent-dark) !important;
    outline-offset: 1px;
    box-shadow: none !important;
}

/* v2.0.62 audit — removed dead .mg-farm-bubble + .mg-farm-dex-unknown CSS
   blocks. The bubble was a v2.0.14 NPC speech-bubble component that got
   replaced by `.mg-farm-scene-npc > *::after`; nothing in JS or templates
   references the old class anymore. Same story for dex-unknown (legacy
   pre-2.0.38 fish-codex placeholder, before dex_<id> backfill landed). */

/* v2.0.71 — second .mg-farm-toast block (was here from v2.0.42) DELETED.
 * Earlier .mg-farm-toast block (search for "v2.0.63 → v2.0.71") is the
 * canonical one. Leaving both let the late-cascade pip rule re-introduce
 * the green dot we just removed. */

/* ---- Reusable confirm icon (e.g. fishing "kept!" / dex complete) ---- */
.mg-farm-icon-check {
    display: inline-block; width: 16px; height: 16px; vertical-align: -2px;
    background: url("assets/ui/icon_check.png") center / contain no-repeat;
    image-rendering: pixelated;
}

/* =======================================================================
 * v2.0.24 — Fishing (catch overlay + fish dex)
 *
 * Performance: the catch suspense is ONE CSS-animated overlay (no rAF,
 * no per-frame JS). Fish sprites all index into a single sheet via
 * background-position. UI reuses the 2.0.23 wood kit.
 * ===================================================================== */

.mg-farm-fish-overlay {
    /* v2.0.75 — reparented to <body>; re-declare token scope. */
    --cell: 96px;
    --bg-soft: #f2e6c8;
    --bg-card: #ffffff;
    --border-warm: #5c4222;
    --border-soft: #a8835c;
    --accent: #6b8e23;
    --accent-dark: #4a6818;
    --text: #2b2014;
    --text-muted: #6b5536;
    font-family: "Cubic 11", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK TC", sans-serif;
    color: var(--text);
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    background: rgba(20, 14, 6, 0.5);
    /* v2.0.96 — overlay is reparented to <body>, so it does NOT
       inherit user-select / tap-highlight rules from .mg-farm-scene.
       During the hold-to-fish mini-game the user's prolonged touch
       was triggering Firefox-mobile's text-selection ghost on the
       whole page (visible blue tint across scene + buttons). Lock
       it down here. */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.mg-farm-fish-overlay[hidden] { display: none; }

.mg-farm-fish-card {
    position: relative;
    width: min(320px, 90vw);
    max-height: 88vh; overflow-y: auto;
    padding: 1.2rem 1.4rem 1.1rem;
    text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}

/* casting phase — bobber + ripple */
.mg-farm-fish-cast { position: relative; width: 100%; height: 58px; }
/* v2.0.241 — bobber is now the official Sprout "fishing water splash"
 * pixel sprite (red-and-white float + teal water ripple), replacing the
 * old smooth CSS red circle that clashed with the pixel-art look. A
 * 4-frame strip (assets/ui/fish_bobber.png, 40×10 = 4×10px) cycled with
 * steps() at 5× scale (→ 50px) so the float bobs and the ripple pulses.
 * The splash is baked into the frames, so the separate ripple ring div
 * is gone. */
.mg-farm-fish-bobber {
    position: absolute; left: 50%; top: 4px;
    width: 50px; height: 50px; margin-left: -25px;
    background-image: url("assets/ui/fish_bobber.png");
    background-size: 200px 50px;           /* 4 frames × 50px */
    background-repeat: no-repeat;
    background-position-x: 0;
    image-rendering: pixelated;
    animation: mg-farm-fish-bob 1.25s steps(4) infinite;
}
@keyframes mg-farm-fish-bob {
    from { background-position-x: 0; }
    to   { background-position-x: -200px; }
}
.mg-farm-fish-casting-text { margin: 0; color: #5b3a16; font-size: 0.95rem; }

/* v2.0.86 — Bite alert: brief "!" cue shown between casting and the
 * minigame so the player gets a visible "the fish bit!" beat. Hot
 * orange-red with a quick pulse so it grabs the eye. */
.mg-farm-fish-bite-alert {
    font-size: 3.6rem;
    line-height: 1;
    text-align: center;
    /* v2.0.242 — match the bobber's red (#bd757e, the float's deeper
     * shade) instead of the old orange-red #d6391f, so the casting screen
     * reads as one colour family. */
    color: #bd757e;
    text-shadow: 0 2px 0 rgba(60, 28, 8, 0.45);
    font-weight: bold;
    margin: 0.4rem 0 0.6rem;
    animation: mg-farm-fish-bite-pulse 0.45s ease-out 2;
}
@keyframes mg-farm-fish-bite-pulse {
    0%   { transform: scale(0.7); opacity: 0.4; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1.0); opacity: 1; }
}

/* reveal phase */
.mg-farm-fish-reveal { animation: mg-farm-pop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes mg-farm-pop {
    0%   { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}
.mg-farm-fish-rarity { font-weight: 700; font-size: clamp(0.85rem, 3.5vw, 0.95rem); letter-spacing: 0.04em; }
.mg-farm-fish-sprite {
    image-rendering: pixelated;
    animation: mg-farm-fish-wiggle 0.9s ease-in-out infinite;
}
@keyframes mg-farm-fish-wiggle {
    0%, 100% { transform: rotate(-4deg); }
    50%      { transform: rotate(4deg); }
}
.mg-farm-fish-name { font-weight: 700; font-size: clamp(1rem, 4.5vw, 1.15rem); color: #4a3318; }
.mg-farm-fish-reward { font-weight: 700; color: #8a6320; font-size: clamp(0.95rem, 4vw, 1.05rem); }   /* v2.0.70 amber */
.mg-farm-fish-dex { color: #7a6e5d; font-size: 0.82rem; }
.mg-farm-fish-card .mg-farm-btn { margin-top: 0.35rem; min-width: 120px; }

/* ---- v2.0.64 — Fishing skill mini-game ----
 * A vertical bar (no jokes, vertical reads as "fishing line going up/down"
 * more naturally than horizontal). Green TARGET ZONE in the middle 30%;
 * INDICATOR drifts down by default, rises while held. Player must keep
 * indicator inside the zone for as many frames as possible — the in-zone
 * frame ratio is the skill score.
 */
.mg-farm-fish-bar {
    /* v2.0.236 — frame swapped from panel.png (warm wood border) to
     * fish_bar_frame.png (UI extension pack — green-outlined pill
     * frame with dark slate fill, native 13×100 rotated to vertical).
     * Reads as a proper game progress-bar widget. The 6/6 slice
     * preserves the rounded end caps; the middle stretches the
     * 1×88 dark slate centre to the box height. */
    position: relative;
    width: 28px;
    height: 220px;
    margin: 0.8rem auto 0.5rem;
    background: transparent;
    border: 6px solid transparent;
    border-image: url("assets/ui/fish_bar_frame.png") 6 fill / 6px / 0 stretch;
    image-rendering: pixelated;
    user-select: none;
    touch-action: none;
}
.mg-farm-fish-bar > * { image-rendering: auto; }
.mg-farm-fish-bar-zone {
    position: absolute;
    left: 2px;
    right: 2px;
    top: 40%;
    height: 20%;   /* v2.0.67 — shrunk from 30% to 20% for tighter timing
                     (matches client ZONE_TOP / ZONE_BOT 40..60) */
    /* v2.0.234 — replaced the sage-green linear-gradient with a flat
     * pixel-art 3-band: dark green top stripe, mid green body, dark
     * green bottom stripe (via solid background + box-shadow insets).
     * Sharp 1px edges read as pixel art instead of soft AA gradient. */
    background: #93c477;
    box-shadow: inset 0 1px 0 #5fa050,
                inset 0 -1px 0 #5fa050;
}
.mg-farm-fish-bar-indicator {
    position: absolute;
    left: 1px; right: 1px;
    top: 50%;
    height: 18px;
    margin-top: -9px;
    /* v2.0.234 — solid pixel-style: 1px dark border, no border-radius,
     * no blurred drop shadow. The earlier rounded corners + soft drop
     * shadow softened the edges in a way that didn't match the pixel
     * UI. Bright orange body with a 1px highlight reads as a wooden
     * indicator block. */
    background: #c89030;
    border: 1px solid #6b4a2a;
    box-shadow: inset 0 1px 0 #e0a85b,
                inset 0 -1px 0 #8b6320;
    /* v2.0.72 — slightly longer + ease-out so each frame step reads
       as smooth motion, not a teleport. Physics tick is 16ms so a
       60ms ease-out tail catches up by the next frame. */
    transition: top 0.06s ease-out, background 0.1s, box-shadow 0.1s;
}
.mg-farm-fish-bar-indicator.is-in-zone {
    /* v2.0.234 — solid pixel green with a hard 1px outer outline
     * instead of the blurred sage glow. Reads as "the bobber lit up". */
    background: #82c074;
    border-color: #3d8030;
    box-shadow: inset 0 1px 0 #b8e0a8,
                inset 0 -1px 0 #5fa050;
}
.mg-farm-fish-bar-progress {
    height: 4px;
    width: 0;
    background: linear-gradient(90deg, #5fa050 0%, #a8d59a 100%);
    border-radius: 2px;
    margin: 0.4rem auto 0;
    max-width: 180px;
    transition: width 0.04s linear;
}
/* v2.0.77 — Stardew-style catch progress meter. The earlier
 * .mg-farm-fish-bar-progress (elapsed time) is no longer used by the
 * mini-game but the rule stays for safety. */
.mg-farm-fish-catch-label {
    margin-top: 0.6rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}
.mg-farm-fish-catch-track {
    height: 10px;
    width: 100%;
    max-width: 200px;
    margin: 0.25rem auto 0;
    background: #2b1f12;
    border: 2px solid var(--border-warm);
    border-radius: 2px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}
.mg-farm-fish-catch-fill {
    height: 100%;
    width: 50%;          /* starting catch progress */
    /* v2.0.109 — sage grass-green gradient. Was olive #8a8d4d. */
    background: linear-gradient(90deg, #5fa050 0%, #a8d59a 100%);
    transition: width 0.06s linear, background 0.15s linear;
}
.mg-farm-fish-catch-fill.is-near-catch {
    /* almost landed — bright grass-green pulse (v2.0.109) */
    background: linear-gradient(90deg, #6fb050 0%, #b8e598 100%);
}
.mg-farm-fish-catch-fill.is-near-escape {
    /* close to losing the fish — amber warning */
    background: linear-gradient(90deg, #a04a1a 0%, #d68a3a 100%);
}

/* Cursor cue: a pointer over the overlay during the mini-game says
   "this whole thing is the button". */
.mg-farm-fish-overlay[data-mg-fish-phase="minigame"] {
    cursor: pointer;
}

/* fish dex grid */
.mg-farm-dex-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.4rem;
}
.mg-farm-dex-slot {
    border: 8px solid transparent;
    border-image: url("assets/ui/slot.png") 12 fill / 8px / 0 stretch;
    image-rendering: pixelated;
    padding: 0.3rem 0.1rem 0.2rem;
    text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
    border-bottom: 8px solid transparent;
    box-shadow: inset 0 -3px 0 var(--tier, transparent);
}
.mg-farm-dex-slot > * { image-rendering: auto; }
.mg-farm-dex-sprite { width: 48px; height: 48px; image-rendering: pixelated; }
/* v2.0.62 audit — removed dead .mg-farm-dex-unknown (legacy "?" placeholder
   before silhouette rendering replaced it). */
/* uncaught fish: show the real sprite as a dark silhouette (so the dex
 * always shows fish shapes), revealed in full colour once caught. */
.mg-farm-dex-silhouette { filter: brightness(0) opacity(0.42); }
.mg-farm-dex-slot.is-locked { filter: grayscale(0.4) brightness(0.98); opacity: 0.85; }
.mg-farm-dex-name {
    font-size: 0.7rem; color: #5b4a30; max-width: 100%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* =======================================================================
 * v2.0.25 — Responsive tidy for small screens (phones)
 *
 * The farm scene itself is already fluid (JS fitViewportToWidth scales it
 * to the viewport) and the layout flex-wraps the scene + sidebar, so the
 * core game plays on both PC and mobile. This block just tidies the
 * wood-framed overlays/modals for narrow widths: the 20px wood border and
 * default paddings feel chunky < ~480px, and the fish dex packs better
 * with slightly smaller cells.
 * ===================================================================== */
@media (max-width: 480px) {
    /* thinner wood frame so the modal interior isn't squeezed */
    .mg-farm-modal-content {
        border-width: 14px;
        border-image: url("assets/ui/panel.png") 14 fill / 14px / 0 stretch;
        padding: 0.3rem 0.6rem 0.7rem;
    }
    /* catch popup: tighter padding, a touch smaller hero sprite via scale */
    .mg-farm-fish-card { padding: 1rem 1rem 0.9rem; }
    .mg-farm-fish-sprite { transform: scale(0.85); }
    /* fish dex: smaller cells → keeps 3–4 per row on a phone */
    .mg-farm-dex-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 0.3rem; }
    .mg-farm-dex-sprite { width: 40px; height: 40px; }
    .mg-farm-dex-name { font-size: 0.62rem; }
    /* v2.0.145 — action-panel button row: equal-width via flex-basis 0
     * (was `auto` = content-sized → "收 鮮奶（可賣 N）" stretched wider
     * than "Lv 2 啡色" upgrade button, looked unbalanced). min-width: 0
     * lets text shrink/wrap cleanly inside the equal slot. */
    .mg-farm-action-buttons .mg-farm-btn { flex: 1 1 0; min-width: 0; min-height: 40px; }
}

/* Coarse-pointer (touch) devices: give the catch overlay's close button and
 * any fishing buttons a comfortable minimum tap target regardless of width. */
@media (pointer: coarse) {
    .mg-farm-fish-card .mg-farm-btn { min-height: 44px; }
}

/* =======================================================================
 * v2.0.29 — pixel font on form controls + inventory wrap + mobile overflow
 * ===================================================================== */

/* Buttons/inputs don't inherit font-family by default (they use the UA
 * system font), so the wood buttons + rename input were NOT using Cubic 11.
 * Make every farm control inherit the pixel font. */
.mg-farm-root button,
.mg-farm-root input,
.mg-farm-root select,
.mg-farm-root textarea { font-family: inherit; }

/* Headings (h1-h6) and other elements DO inherit font-family by default,
 * but a parent WordPress theme rule like `h3 { font-family: <theme> }`
 * beats an inherited value (any matching declaration outranks inheritance).
 * That's why the "背包" <h3> was rendering in the theme font instead of
 * Cubic 11. Forcing inherit on every descendant — at .mg-farm-root class
 * specificity — neutralises such theme rules. (Same island-reset pattern
 * already used for font-weight below.) Note: applied to descendants only,
 * NOT .mg-farm-root itself, which must keep its own Cubic-11 declaration. */
.mg-farm-root * { font-family: inherit; }

/* v2.0.84 — Same font-inherit sweep for the reparented containers.
 * Modal, fish-overlay, and toast stack were lifted out of .mg-farm-root
 * to <body> in v2.0.75 (escapes the transformed-ancestor position:fixed
 * breakage). The earlier .mg-farm-root descendant selector stopped
 * reaching them, so their buttons / inputs / select / textarea fell
 * back to the user-agent system font (e.g. the rename-currency input
 * + every modal-internal button were rendering in Arial/system-ui).
 * Repeat the same family inheritance + descendant force on each
 * reparented island. */
.mg-farm-modal,
.mg-farm-fish-overlay,
.mg-farm-toast-stack {
    /* Defensive: the host containers themselves already get Cubic 11
     * via their main rule block, but state these explicitly so a stray
     * !important from a parent theme can't kill the family chain. */
    font-family: "Cubic 11", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK TC", sans-serif !important;
}
.mg-farm-modal *,
.mg-farm-fish-overlay *,
.mg-farm-toast-stack * { font-family: inherit !important; }
.mg-farm-modal button,
.mg-farm-modal input,
.mg-farm-modal select,
.mg-farm-modal textarea,
.mg-farm-fish-overlay button,
.mg-farm-fish-overlay input,
.mg-farm-toast-stack button { font-family: inherit !important; }

/* Mobile right-edge overflow: flex children default to min-width:auto and
 * refuse to shrink below their content's min size, pushing past the screen.
 * Allow the layout chain to shrink. */
.mg-farm-main { flex-wrap: wrap; }
.mg-farm-sidebar { min-width: 0; }
.mg-farm-inventory,
.mg-farm-action-panel,
.mg-farm-inv-list { min-width: 0; max-width: 100%; }

/* Inventory: compact chips that wrap SEVERAL per row (not one-per-row).
 * The one-per-row + overflow was the same min-width:auto trap combined with
 * white-space:nowrap on long labels — let chips shrink and ellipsize the
 * name instead of forcing a full-width row. */
.mg-farm-inv-item {
    display: inline-flex; align-items: center; gap: 0.15rem;
    flex: 0 1 auto; min-width: 0; max-width: 100%;
}
.mg-farm-inv-item > .mg-farm-inv-item-name {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Inventory chip icon (seed packet / decoration sprite). Pixel-crisp. */
.mg-farm-inv-item-icon {
    flex: 0 0 auto;
    width: 20px; height: 20px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
}
/* v2.0.38 — fish chips draw from the shared sprite sheet via inline
 * fishSpriteStyle (sets background-image + size + position). Override
 * the `contain` sizing so the sheet's `background-size: NxM px` from
 * the inline style wins; the chip is 24px to match fishSpriteStyle. */
.mg-farm-inv-item-icon-fish {
    width: 24px; height: 24px;
    background-size: auto;          /* let inline style set explicit sheet dims */
    background-repeat: no-repeat;
    background-position: 0 0;       /* inline style overrides with the cell offset */
}

/* =======================================================================
 * v2.0.30 — normal font weight everywhere
 *
 * Cubic 11 is a single-weight (400) pixel font, so any font-weight > 400
 * renders as browser faux-bold (blurry / doubled on a pixel face). Force
 * normal weight across the farm — visual hierarchy comes from size and
 * colour (the pixel-art way), not weight.
 * ===================================================================== */
.mg-farm-root,
.mg-farm-root * { font-weight: normal; font-style: normal; }

/* =======================================================================
 * v2.0.68 — Daily Quest Panel
 * v2.0.70 — Restyle: dropped per-row wood-panel 9-slice (5 identical
 *           rows blurred together); added icon column for visual
 *           differentiation; alternating subtle row tints; replaced
 *           neon moss-green (#6b8e3d) with olive-amber (#8a8d4d /
 *           #c89030) so the whole quest panel feels of-a-piece with
 *           the wood theme.
 * v2.0.97 — Full redesign. Each quest is now a proper card with a
 *           cream-paper surface, soft shadow, and clear section
 *           hierarchy: title row → progress + count row → reward +
 *           status row. Replaces the cramped 3-column grid where the
 *           reward + status competed for the same vertical space.
 * ===================================================================== */
.mg-farm-quest-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0;
    margin: 0;
}
.mg-farm-quest-row {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 0.7rem;
    row-gap: 0.35rem;
    padding: 0.7rem 0.85rem;
    background: #f5e8c8;
    border-radius: 8px;
    border: 2px solid #a8835c;
    border-left: 6px solid #8a6a3a;
    box-shadow: 0 2px 0 rgba(74, 50, 22, 0.18),
                inset 0 1px 0 rgba(255, 248, 220, 0.6);
    transition: border-left-color 0.2s, background 0.2s;
}
.mg-farm-quest-row.is-alt {
    background: #ecdcb4;
}
.mg-farm-quest-row.is-ready {
    background: #ffeac2;
    border-left-color: #d68a30;
    border-color: #c89030;
    box-shadow: 0 2px 0 rgba(110, 70, 20, 0.25),
                inset 0 1px 0 rgba(255, 252, 220, 0.7),
                0 0 0 2px rgba(232, 178, 90, 0.35);
}
.mg-farm-quest-row.is-claimed {
    opacity: 0.6;
    border-left-color: #a8835c;
    box-shadow: none;
}

.mg-farm-quest-icon {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    /* v2.0.97 — icon sits on a small wood disc for visual weight. */
    width: 42px;
    height: 42px;
    background: rgba(168, 130, 75, 0.25);
    border-radius: 50%;
    border: 1.5px solid rgba(122, 89, 51, 0.4);
    font-size: 1.4rem;
    line-height: 1;
}
.mg-farm-quest-icon .mg-ic {
    margin: 0;
    vertical-align: middle;
    width: 1.5em;
    height: 1.5em;
}
.mg-farm-quest-label {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    color: #2b1a08;
    font-size: 1rem;
    line-height: 1.25;
    align-self: end;
}
.mg-farm-quest-progress {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}
.mg-farm-quest-bar {
    flex: 1;
    height: 9px;
    background: rgba(60, 36, 20, 0.22);
    border-radius: 5px;
    overflow: hidden;
    min-width: 80px;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.15);
}
.mg-farm-quest-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #b8782a 0%, #e8b85a 100%);
    transition: width 0.3s ease-out;
    border-radius: 5px;
}
.mg-farm-quest-count {
    font-size: 0.85rem;
    color: #5a4220;
    min-width: 52px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.mg-farm-quest-reward {
    /* v2.0.97 — moved reward up next to title row, right-aligned.
       Was previously on its own line below progress, fighting for
       space against the action column. */
    grid-column: 3 / 4;
    grid-row: 1 / 2;
    font-size: 0.88rem;
    color: #6a4a18;
    align-self: end;
    white-space: nowrap;
}
.mg-farm-quest-reward .mg-ic {
    vertical-align: -0.18em;
}
.mg-farm-quest-action {
    grid-column: 3 / 4;
    grid-row: 2 / 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 78px;
}
.mg-farm-quest-claim-btn {
    padding: 0.4rem 0.7rem !important;
    min-width: 78px;
    font-size: 0.88rem !important;
}
.mg-farm-quest-pill {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    /* v2.0.109 — sage/grass green family matching the ground tone
       (#93c477), replacing the previous olive #7a9c4e which read
       as khaki/muddy. Now the 已收 pill has the same fresh
       grass-green feel as the playable field. */
    background: rgba(130, 192, 116, 0.40);
    color: #2d5018;
    border: 1px solid rgba(95, 160, 80, 0.55);
    border-radius: 4px;
    font-size: 0.82rem;
}
.mg-farm-quest-hint {
    font-size: 0.85rem;
    color: #7a6240;
    padding: 0.15rem 0;
}

.mg-farm-quest-footer {
    margin-top: 0.8rem;
    padding-top: 0.6rem;
    border-top: 1px dashed rgba(122, 89, 51, 0.4);
    text-align: center;
}
.mg-farm-quest-footer .mg-farm-hint { margin: 0.3rem 0; }
.mg-farm-quest-bonus-done {
    color: #8a6320;
    font-size: 0.95rem;
    margin: 0.4rem 0 0;
}
.mg-farm-quest-bonus-btn {
    margin-top: 0.4rem;
    min-width: 220px;
}

/* =======================================================================
 * v2.0.170 — Layout picker (house door → 換農場樣式)
 *
 * Modal grid of selectable farm looks, built from garden.layouts_info.
 * Each card: emoji + name; the active one is marked, locked ones show
 * a 🔒 + unlock threshold and are dimmed. Style follows the warm-wood
 * token palette used everywhere else in the farm UI.
 * ===================================================================== */
.mg-farm-layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.6rem;
    margin: 0.2rem 0 0.6rem;
}
.mg-farm-layout-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.7rem 0.5rem 0.6rem;
    border: 2px solid var(--border-soft);
    border-radius: 10px;
    /* v2.0.178 — `!important` defends against WP host themes that style
     * `button { background: <brand-color> }` (saw red bg leaking through
     * on user's site). The state-state rules below also lock background
     * so :hover / :active / :focus don't flash a theme colour. */
    background: var(--bg-soft) !important;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-align: center;
    transition: transform 0.08s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    /* a thin accent strip along the top tints each card to its theme */
    box-shadow: inset 0 4px 0 0 var(--card-accent, var(--accent));
}
.mg-farm-layout-card:hover {
    transform: translateY(-2px);
    border-color: var(--card-accent, var(--accent));
    background: var(--bg-soft) !important;   /* v2.0.178 lock vs WP theme */
}
.mg-farm-layout-card:focus-visible {
    outline: 2px solid var(--accent-dark);
    outline-offset: 2px;
    background: var(--bg-soft) !important;   /* v2.0.178 lock vs WP theme */
}
.mg-farm-layout-card:active {
    background: var(--bg-soft) !important;   /* v2.0.178 lock vs WP theme */
}
.mg-farm-layout-card.is-current {
    border-color: var(--card-accent, var(--accent));
    box-shadow: inset 0 4px 0 0 var(--card-accent, var(--accent)),
                0 0 0 2px var(--card-accent, var(--accent)) inset;
    cursor: default;
}
.mg-farm-layout-card.is-current:hover { transform: none; }
.mg-farm-layout-card.is-locked {
    cursor: not-allowed;
    opacity: 0.62;
    filter: grayscale(0.35);
}
.mg-farm-layout-card.is-locked:hover { transform: none; border-color: var(--border-soft); }
.mg-farm-layout-emoji {
    font-size: 1.9rem;
    line-height: 1;
    /* v2.0.231 — formerly hosted a Unicode emoji, now hosts a pixel
     * sprite via inner .mg-ic. The font-size still controls the icon
     * size (mg-ic uses 1.2em width/height baseline; emoji slot lets
     * the icon scale relative to the emoji slot). */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.mg-farm-layout-emoji .mg-ic {
    width: 1.9rem;
    height: 1.9rem;
    margin: 0;
}
.mg-farm-layout-name {
    font-weight: 600;
    font-size: 0.95rem;
}
.mg-farm-layout-current,
.mg-farm-layout-lock {
    display: inline-flex;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.mg-farm-layout-current { color: var(--accent-dark); font-weight: 600; }
.mg-farm-layout-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.2;
}
.mg-farm-layout-note { margin: 0.2rem 0 0; font-size: 0.8rem; }
@media (max-width: 560px) {
    .mg-farm-layout-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.5rem; }
    .mg-farm-layout-card { min-height: 96px; }
    .mg-farm-layout-emoji { font-size: 1.7rem; }
    .mg-farm-layout-emoji .mg-ic { width: 1.7rem; height: 1.7rem; }
}

/* v2.0.216 — colour picker grid (house roof + cat character colours).
 * Same shape as the layout picker so the modals feel consistent, but
 * the swatch IS the sprite — no emoji, no accent strip. The current
 * pick gets a green border + checkmark badge. Click anywhere on a
 * non-current card to apply. */
.mg-farm-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 0.55rem;
    margin: 0.2rem 0 0.6rem;
}
.mg-farm-color-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.55rem 0.5rem 0.5rem;
    border: 2px solid var(--border-soft);
    border-radius: 10px;
    background: var(--bg-soft) !important;
    color: var(--text);
    cursor: pointer;
    text-align: center;
    transition: transform 0.08s ease, border-color 0.12s ease;
}
.mg-farm-color-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    background: var(--bg-soft) !important;
}
.mg-farm-color-card.is-current {
    border-color: var(--accent-dark);
    box-shadow: 0 0 0 2px var(--accent-dark) inset;
    cursor: default;
}
.mg-farm-color-card.is-current:hover { transform: none; }
.mg-farm-color-img {
    width: 64px; height: 64px;
    image-rendering: pixelated; image-rendering: crisp-edges;
    /* Center sprite in box; preserve aspect. House sprites are
     * 64×64 native and render 1:1 at this size. */
    object-fit: contain;
}
/* Cat sprites are tighter (32×32 trimmed avatar) — display at the
 * same visual scale via height: contain inside the same box.
 * The cat sits a bit lower so head shows; align bottom. */
.mg-farm-color-img-cat {
    width: 56px; height: 56px;
    object-position: center bottom;
}
.mg-farm-color-name {
    font-weight: 600;
    font-size: 0.9rem;
}
.mg-farm-color-current {
    position: absolute;
    top: 4px; right: 4px;
    display: inline-flex;
    align-items: center;
    color: var(--accent-dark);
}
@media (max-width: 560px) {
    .mg-farm-color-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 0.45rem; }
    .mg-farm-color-img { width: 56px; height: 56px; }
    .mg-farm-color-img-cat { width: 48px; height: 48px; }
}

/* =======================================================================
 * v2.0.75 — Pixel-art emoji icon system
 *
 * Inline icon class to replace native browser emoji rendering, which
 * clashed with the pixel-art game world (Apple round / Samsung flat /
 * Windows colourful glyphs all rendered in the same UI). Each icon is
 * a 16×16 (or close) pixel-art PNG from Sprout Lands or hand-drawn,
 * displayed inline at text-baseline.
 *
 * Use:  <span class="mg-ic mg-ic-coin"></span>
 * Or:   MGFarm.ic('coin')  →  same HTML
 *
 * Note: emoji INSIDE plain-string toast messages stays as native
 * emoji (toast lib uses textContent + can't render HTML); only the
 * scene overlays + buttons + hints that own their HTML get swapped.
 * ===================================================================== */
.mg-ic {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    vertical-align: -0.25em;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    margin-right: 0.15em;
    flex-shrink: 0;
}
.mg-ic-coin     { background-image: url("assets/ui/emoji/coin.png"); }
.mg-ic-seed     { background-image: url("assets/ui/emoji/seed.png"); }
.mg-ic-harvest  { background-image: url("assets/ui/emoji/harvest.png"); }
.mg-ic-egg      { background-image: url("assets/ui/emoji/egg.png"); }
.mg-ic-milk     { background-image: url("assets/ui/emoji/milk.png"); }
.mg-ic-rod      { background-image: url("assets/ui/emoji/rod.png"); }
.mg-ic-water    { background-image: url("assets/ui/emoji/water.png"); }
.mg-ic-hoe      { background-image: url("assets/ui/emoji/hoe.png"); }
.mg-ic-lock     { background-image: url("assets/ui/emoji/close.png"); }  /* v2.0.146 — was lock.png (self-drawn padlock); switched to Sprout Lands' official X (close.png) per user — "locked" reads as "X / denied" which is consistent with the rest of the emoji pack and pixel-art accurate. */
.mg-ic-unlock   { background-image: url("assets/ui/emoji/unlock.png"); }
.mg-ic-gift     { background-image: url("assets/ui/emoji/gift.png"); }
.mg-ic-basket   { background-image: url("assets/ui/emoji/basket.png"); }
.mg-ic-fire     { background-image: url("assets/ui/emoji/fire.png"); }
.mg-ic-sparkle  { background-image: url("assets/ui/emoji/sparkle.png"); }
.mg-ic-star     { background-image: url("assets/ui/emoji/star.png"); }
.mg-ic-book     { background-image: url("assets/ui/emoji/book.png"); }
.mg-ic-house    { background-image: url("assets/ui/emoji/house.png"); }  /* v2.0.170 — derived from objects/small_house.png for the layout-picker door panel */
.mg-ic-soil     { background-image: url("assets/ui/emoji/soil.png"); }
.mg-ic-water-wave { background-image: url("assets/ui/emoji/water_wave.png"); }
.mg-ic-edit     { background-image: url("assets/ui/emoji/edit.png"); }
.mg-ic-check    { background-image: url("assets/ui/emoji/check.png"); }
.mg-ic-close    { background-image: url("assets/ui/emoji/close.png"); }
/* v2.0.256 — chat header icon. Reuses the launcher PNG (Sprout Lands
 * "speech bubble with three dots") rather than duplicating the file
 * into the emoji/ subfolder. Used by the chat panel title via
 * MGFarm.ic('chat'). */
.mg-ic-chat     { background-image: url("assets/ui/chat-launcher.png"); }
/* v2.0.267 — mailbox modal title icon. Reuses the NPC sprite directly
 * (same convention as .mg-ic-chat). Sprout Lands pixel-art mailbox,
 * matched to the in-scene decor so the modal feels continuous with
 * the world. Used by openMailbox via MGFarm.ic('mailbox'). */
.mg-ic-mailbox  { background-image: url("assets/objects/mailbox.png"); }
.mg-ic-cow      { background-image: url("assets/ui/emoji/cow.png"); }
.mg-ic-chicken  { background-image: url("assets/ui/emoji/chicken.png"); }
.mg-ic-tree     { background-image: url("assets/ui/emoji/tree.png"); }
.mg-ic-apple    { background-image: url("assets/ui/emoji/apple.png"); }
/* v2.0.230 — replacements for previous Unicode emoji buttons:
 * 🌾 (farm style) → wheat sprite derived from crops/wheat_item.png
 * 🐱 (cat color)  → cream cat sprite from avatar_down_0.png */
.mg-ic-wheat    { background-image: url("assets/ui/emoji/wheat.png"); }
.mg-ic-cat      { background-image: url("assets/ui/emoji/cat.png"); }
/* v2.0.231 — layout-picker icons (3 active layouts: meadow/winter/sakura;
 * v2.0.232 trimmed stale garden/autumn/cozy/pine/desert classes after
 * those layouts were removed from class-mg-farm-catalog.php). meadow
 * was updated v2.0.232 from grass_variant_2.png to the official
 * grass-n-ground-tile-items.png r2c1 (a small grass-on-dirt patch). */
.mg-ic-meadow   { background-image: url("assets/ui/emoji/meadow.png"); }
.mg-ic-winter   { background-image: url("assets/ui/emoji/winter.png"); }
.mg-ic-sakura   { background-image: url("assets/ui/emoji/sakura.png"); }
.mg-ic-map      { background-image: url("assets/ui/emoji/map.png"); }
/* v2.0.233 — pixel-art ♪ note (8×12 eighth note, hand-drawn). Used by
 * the header SFX toggle + the in-scene radio sprite. */
.mg-ic-note     { background-image: url("assets/ui/emoji/note.png"); }
/* v2.0.238 — two beamed eighth notes (♫), 11×14 hand-drawn pixel art (two
 * the same brown as note.png. Used by the header 農場電台 music toggle. */
.mg-ic-note2    { background-image: url("assets/ui/emoji/note2.png"); }
.mg-ic-orange   { background-image: url("assets/ui/emoji/orange.png"); }
.mg-ic-pear     { background-image: url("assets/ui/emoji/pear.png"); }
.mg-ic-peach    { background-image: url("assets/ui/emoji/peach.png"); }
/* v2.0.154 — berry icons for ready-bubble + inventory + sell card.
 * Reuse the single-berry item PNGs from objects/ (already shipped as
 * inventory icons in v2.0.153); no need to duplicate into emoji/ */
.mg-ic-berry_red     { background-image: url("assets/objects/item_berry_red.png"); }
.mg-ic-berry_magenta { background-image: url("assets/objects/item_berry_magenta.png"); }
.mg-ic-berry_blue    { background-image: url("assets/objects/item_berry_blue.png"); }

/* Bigger variant for centred labels / overlays */
.mg-ic-lg { width: 2em; height: 2em; vertical-align: -0.6em; }

/* =====================================================================
 * v2.0.244 — Farm MP M1: visit banner + presence avatars.
 *
 * The visit banner sits ABOVE the .mg-farm-header (inserted as first
 * child of .mg-farm-root by farm.js _injectVisitBanner). The presence
 * avatars are siblings of .mg-farm-player inside the scene; they
 * inherit the --cell var and use the same --x/--y positioning.
 * ===================================================================== */

/* ---- Visit banner ("你而家喺 X 嘅農場 [返主農場]") ---- */
.mg-farm-visit-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.35rem 0.6rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(180deg,
        rgba(150, 110, 60, 0.95) 0%,
        rgba(120,  86, 44, 0.95) 100%);
    border: 2px solid var(--border-warm);
    border-radius: 5px;
    color: var(--text-on-dark);
    font-size: 0.95rem;
    box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.25),
                0 1px 0 rgba(0, 0, 0, 0.2);
}
.mg-farm-visit-banner__label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mg-farm-visit-banner__back {
    flex: 0 0 auto;
    /* tighter than the standard wood button — banner is a slim strip */
    padding: 0.25rem 0.7rem;
    font-size: 0.85rem;
}

/* ---- Presence avatars (other players in the scene) ----
 * Same positioning system as .mg-farm-player (above). The avatar
 * div itself takes 1×1 cell; the name label floats above as a small
 * pill. pointer-events:none — visitors can't interact with each
 * other's avatars (M1 baseline). M4 may add tap-to-emoji later. */
.mg-farm-presence-player {
    position: absolute;
    left: calc(var(--x, 0) * var(--cell));
    top:  calc(var(--y, 0) * var(--cell));
    width:  var(--cell);
    height: var(--cell);
    background-repeat: no-repeat;
    pointer-events: none;
    /* Gentle "this is a remote player" cue — soft glide between cells
     * so they read as someone else moving, not teleporting.
     *
     * v2.0.248 — duration raised from 0.4s to 1.5s linear, matching the
     * visit-mode poll interval (POLL_INTERVAL_VISIT in farm.js). With
     * linear easing + duration === poll interval, the avatar's visual
     * speed naturally tracks the real walk speed: if the other player
     * moves N cells in one poll window, the avatar interpolates N cells
     * over 1.5s, which is the same N cells / 1.5s rate as actual
     * walking. No matter how fast or slow they move, the glide reads
     * right. */
    transition: left 1.5s linear, top 1.5s linear;
    will-change: left, top;
}
/* v2.0.260 — Nametag repositioned BELOW the avatar (was above) and
 * restyled to match the speech bubble's cream+wood-dark theme (was
 * a generic dark semi-transparent pill that read as a browser
 * tooltip, not part of the pixel-art world). User: 「nametag 及
 * bubble，我覺得可以放下方兩格，貼近角色，然後 nametag 及 bubble
 * 設計的 color 是跟了 game 的 right?」 — confirming bubble follows
 * game palette, asking nametag to match. Now both share
 * --mg-chat-tile-bg + --mg-chat-wood-dark vars. */
.mg-farm-presence-name {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    margin-top: 2px;
    padding: 0 5px;
    background: var(--mg-chat-tile-bg, #fffaee);
    color: var(--mg-chat-wood-dark, #6c4724);
    border: 1px solid var(--mg-chat-wood-dark, #6c4724);
    border-radius: 3px;
    font-size: 0.65rem;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 1px 1px 0 rgba(108, 71, 36, 0.30);
}

/* ---- v2.0.246 — visit-mode owner-only UI hide ----
 * .is-visit-mode is set on .mg-farm-root by _injectVisitBanner. The
 * privacy fix in build_visit_view strips host's currency / inventory
 * / lifetime / unlocked-crops / available-packs / daily-quests from
 * the response payload, so the header currency would otherwise show
 * "0 菜幣" and the sidebar inventory would render as empty — both
 * misleading. Hide the owner-only chrome entirely in visit mode.
 *
 * Kept visible: action-panel (visitor's per-cell actions), header
 * toggles (music/sfx are the VISITOR's own settings, persisted on
 * their account), visit banner. */
.mg-farm-root.is-visit-mode .mg-farm-currency,
.mg-farm-root.is-visit-mode .mg-farm-lifetime,
.mg-farm-root.is-visit-mode .mg-farm-shop-buttons,
.mg-farm-root.is-visit-mode .mg-farm-inventory {
    display: none;
}

/* v2.0.251 — visit-banner right-side cluster holding the relocated
 * music+sfx toggles + the back button. Inline flex so the toggles
 * sit immediately left of the back button with a small gap, and the
 * whole cluster is pushed right by the banner's outer space-between.
 *
 * The header itself is fully hidden in visit mode now that all its
 * visible-in-visit-mode children (the toggles) live in the banner —
 * what's left would be a ~2-button empty bar, dead UI space. */
.mg-farm-visit-banner__right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.mg-farm-root.is-visit-mode .mg-farm-header {
    display: none;
}

/* =================================================================
 * v2.0.252 — Farm MP M4a: persistent per-farm chat.
 *
 * Three visual surfaces:
 *
 *   1. Chat panel — collapsible bottom-right widget. Closed state =
 *      square pixel-art launcher button with optional unread badge
 *      (was circular pre-2.0.253 — feedback was that two third-party
 *      site widgets are already circular floating buttons; matching
 *      shape made the chat read as a sibling support widget rather
 *      than a game element). Open state = ~280×360 cozy pixel-art
 *      panel with message list, single flat emoji grid sorted by
 *      usage (was 6 thematic tabs pre-2.0.253), and a text input row.
 *
 *   2. Speech bubble — transient overlay that floats above the
 *      speaker's avatar (.mg-farm-player for the local player,
 *      [data-mg-presence-uid=N] for other in-scene visitors).
 *      3.2s lifetime, fade-out on `.is-fading`.
 *
 *   3. Emoji burst — bigger version of the picked emoji pops in
 *      above the bubble, drifts up, fades. 1.5s lifetime.
 *
 * Typography: font-family is NOT set on the chat panel — it
 * inherits Cubic 11 from .mg-farm-root via the existing wildcard
 * `.mg-farm-root * { font-family: inherit }`. Keeps the chat
 * surfaces visually consistent with the rest of the farm UI
 * (also matches user feedback "字體請全用arcade" in 2.0.253).
 *
 * Palette: kept as bespoke chat-scope vars but DECLARED ON
 * .mg-farm-root so the speech bubble + emoji burst (which live
 * under .mg-farm-player, not .mg-farm-chat-panel) also inherit
 * them and pick up future theme overrides cleanly.
 * ================================================================= */

.mg-farm-root {
    --mg-chat-cream:      #f5ecd9;
    --mg-chat-cream-deep: #ead6b0;
    --mg-chat-sage:       #7da080;
    --mg-chat-sage-dark:  #4f6e54;
    --mg-chat-wood:       #9a6b3c;
    --mg-chat-wood-dark:  #6c4724;
    --mg-chat-berry:      #c84858;
    --mg-chat-berry-soft: #e9a3ad;
    --mg-chat-tile-bg:    #fffaee;
    --mg-chat-shadow:     #dec79c;
}

.mg-farm-chat-panel {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 40;
    color: #2d2620;
}

/* ---------- Collapsed launcher ----------
 *
 * Square pixel-art tile, NOT circular (2.0.253 — feedback was the
 * site already has two circular third-party widgets, a third would
 * cluster). Sharp 2px border, minimal radius (4px = barely-rounded
 * pixel-art corners), drop shadow for depth. The chat-icon img
 * inside is centred via flex.
 *
 * Icon: 2.0.255 swapped the 💬 emoji glyph for a Sprout Lands
 * "speech bubble with three dots" icon (16px pixel art, white tint,
 * upscaled to 24×24 via image-rendering: pixelated). User feedback
 * was the emoji didn't match the rest of the cozy pixel-art UI.
 */

.mg-farm-chat-panel.is-closed {
    width: auto;
    height: auto;
}
/* v2.0.257 — Launcher button site-theme defence.
 *
 * Bug: 2.0.256 deployed and the launcher's "brown" 2px border was
 * rendering RED. User: "還是紅色。。。button" + screenshot showing
 * the sage green tile with a bright red frame around it.
 *
 * Root cause: same `button { border-color: red !important }` site
 * theme attack that hit the send button (2.0.256), the input border
 * (2.0.255), and the rename-btn (2.0.42). The launcher had a plain
 * `border: 2px solid wood-dark` with no !important — theme won
 * cascade and painted red over the brown.
 *
 * Audit miss: when I hardened close + send in 2.0.256 I should have
 * caught the launcher too — it's the same button, same surface, same
 * attack. This is the third button in the chat surface getting the
 * same patch and it should have been a single pass.
 *
 * Fix: same defence-in-depth as the other chat buttons:
 *   - `border: 0 !important` — kill the border the theme wants to paint
 *   - Visual 2px frame drawn via `box-shadow: inset 0 0 0 2px
 *     wood-dark`, combined with the existing 3x3 NES-style drop
 *     shadow + soft halo in one box-shadow list (theme has no
 *     box-shadow attack rule)
 *   - All paint properties on every interaction state get
 *     `!important`, with `.mg-farm-root` selector prefix to bump
 *     specificity past any theme-injected `button:hover` rule */
.mg-farm-chat-launcher {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 4px;
    border: 0 !important;
    outline: 0 !important;
    background: var(--mg-chat-sage) !important;
    cursor: pointer;
    box-shadow: inset 0 0 0 2px var(--mg-chat-wood-dark),
                3px 3px 0 var(--mg-chat-wood-dark),
                0 2px 6px rgba(0,0,0,0.18);
    transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mg-farm-chat-launcher img {
    width: 28px;
    height: 28px;
    image-rendering: pixelated;
    display: block;
}
.mg-farm-root .mg-farm-chat-launcher:hover,
.mg-farm-root .mg-farm-chat-launcher:focus,
.mg-farm-root .mg-farm-chat-launcher:focus-visible {
    transform: translateY(-1px);
    background: var(--mg-chat-sage-dark) !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: inset 0 0 0 2px var(--mg-chat-wood-dark),
                3px 4px 0 var(--mg-chat-wood-dark),
                0 4px 10px rgba(0,0,0,0.2) !important;
}
.mg-farm-root .mg-farm-chat-launcher:active {
    transform: translate(1px, 1px);
    background: var(--mg-chat-sage-dark) !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: inset 0 0 0 2px var(--mg-chat-wood-dark),
                2px 2px 0 var(--mg-chat-wood-dark) !important;
}
.mg-farm-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--mg-chat-berry);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    line-height: 18px;
    text-align: center;
    border: 2px solid var(--mg-chat-tile-bg);
    box-sizing: content-box;
    pointer-events: none;
}

/* ---------- Open panel ---------- */

.mg-farm-chat-panel.is-open {
    width: 280px;
    max-width: calc(100vw - 24px);
    height: 360px;
    max-height: calc(100vh - 80px);
    background: var(--mg-chat-tile-bg);
    border: 2px solid var(--mg-chat-wood);
    border-radius: 8px;
    box-shadow: 3px 3px 0 var(--mg-chat-shadow), 0 6px 16px rgba(45,38,32,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mg-farm-chat-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    /* v2.0.271 — user wants the header to MATCH the action-panel's
     * sell-button background (--bg-soft #f2e6c8), not contrast with
     * it. (2.0.270 went dark by mistake — misread the request.) Now
     * the chat header tone is consistent with the sell btn. */
    background: var(--bg-soft);
    border-bottom: 2px solid var(--mg-chat-wood);
}
.mg-farm-chat-title {
    font-weight: 600;
    color: var(--mg-chat-wood-dark);
    font-size: 13px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* v2.0.256 — close button hosts an <span class="mg-ic mg-ic-close">
 * child (Sprout pixel X) instead of a "×" text glyph. Hardened
 * against the same site-theme attack the rename-btn pattern defends
 * against: `button:hover { background: red !important; border-color:
 * red !important }`. All paint properties get `!important`, border/
 * outline are forced to 0 so theme red has nothing to draw on, hover
 * tint is applied via background-color with !important. */
.mg-farm-chat-close {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer;
    padding: 0;
    border-radius: 3px;
}
.mg-farm-chat-close .mg-ic {
    width: 16px;
    height: 16px;
    margin: 0;
    vertical-align: middle;
}
.mg-farm-root .mg-farm-chat-close:hover,
.mg-farm-root .mg-farm-chat-close:focus,
.mg-farm-root .mg-farm-chat-close:focus-visible {
    /* v2.0.271 — header light again (--bg-soft); wood-tint hover */
    background: rgba(108, 71, 36, 0.12) !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
}
.mg-farm-root .mg-farm-chat-close:active {
    background: rgba(108, 71, 36, 0.20) !important;
    border: 0 !important;
    outline: 0 !important;
    transform: translateY(1px);
}

.mg-farm-chat-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--mg-chat-tile-bg);
}
.mg-farm-chat-msg {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.35;
    word-break: break-word;
}
.mg-farm-chat-msg.is-pending {
    opacity: 0.55;
}
.mg-farm-chat-speaker {
    color: var(--mg-chat-sage-dark);
    font-weight: 600;
    flex: 0 0 auto;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mg-farm-chat-speaker::after {
    content: '：';
}
.mg-farm-chat-body {
    color: #2d2620;
    flex: 1 1 auto;
}
.mg-farm-chat-emoji-img {
    width: 32px;
    height: 32px;
    vertical-align: middle;
    image-rendering: pixelated;
}

/* ---------- Emoji picker — single flat grid sorted by usage ----------
 *
 * 2.0.253: tabs removed (user feedback "不要為emoji分類，只要一個
 * record住常用emoji"). All 38 emoji are rendered in one grid, sorted
 * by per-user click count (tracked in localStorage by JS). The
 * grid scrolls vertically when contents overflow.
 */

.mg-farm-chat-emoji-grid {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
    padding: 6px;
    background: var(--mg-chat-tile-bg);
    border-top: 1px dashed rgba(154, 107, 60, 0.3);
    /* v2.0.256 — was 160px (~44% of the 360px panel). User feedback
     * "emoji不應佔過多畫面,30%就好" — cap at 108px so the message
     * list keeps the majority of the vertical budget. Grid still
     * scrolls when 38 emojis don't fit visible. */
    max-height: 108px;
    overflow-y: auto;
}
/* v2.0.257 — emoji buttons get the same defence preemptively. Was
 * `border: 1px solid transparent` + `:hover border-color: sage` which
 * the site theme's `button { border-color: red !important }` would
 * paint red across 38 buttons. Visual hover tint moved to inset
 * box-shadow so the theme can't paint it. */
.mg-farm-chat-emoji-btn {
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    padding: 2px;
    cursor: pointer;
    border-radius: 4px;
    line-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mg-farm-root .mg-farm-chat-emoji-btn:hover,
.mg-farm-root .mg-farm-chat-emoji-btn:focus,
.mg-farm-root .mg-farm-chat-emoji-btn:focus-visible {
    background: rgba(125, 160, 128, 0.18) !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: inset 0 0 0 1px rgba(125, 160, 128, 0.5);
}
.mg-farm-root .mg-farm-chat-emoji-btn:active {
    background: rgba(200, 72, 88, 0.15) !important;
    border: 0 !important;
    outline: 0 !important;
}
.mg-farm-chat-emoji-btn img {
    width: 28px;
    height: 28px;
    image-rendering: pixelated;
}

/* ---------- Input row ---------- */

.mg-farm-chat-input-row {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    background: var(--mg-chat-cream-deep);
    border-top: 2px solid var(--mg-chat-wood);
    margin: 0;
}
.mg-farm-chat-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 8px;
    /* v2.0.255 — Border drawn via inset box-shadow (same pattern as
     * .mg-farm-rename-input). The site theme injects `input:focus {
     * border-color: red !important; outline: red !important }` and a
     * plain border-color was being overridden — user feedback after
     * 2.0.254: "input field hover不應是紅色！！ 錯了 被蓋了". With
     * border: 0 !important the theme's red border has no border to
     * paint; the inset shadow IS our visual frame. */
    border: 0 !important;
    outline: 0 !important;
    border-radius: 4px;
    background: var(--mg-chat-tile-bg);
    box-shadow: inset 0 0 0 2px var(--mg-chat-wood);
    font-family: inherit;
    font-size: 13px;
    color: #2d2620;
}
/*
 * Focus state: subtle inner shadow darkening from wood → wood-dark,
 * still no outline, still no border. Same defence-in-depth so the
 * theme can't sneak in a coloured focus ring. 2.0.254 reverted the
 * 2.0.253 site-red; 2.0.255 ALSO makes the rule actually stick.
 */
.mg-farm-root .mg-farm-chat-input:focus,
.mg-farm-root .mg-farm-chat-input:focus-visible {
    border: 0 !important;
    outline: 0 !important;
    background: var(--mg-chat-tile-bg) !important;
    box-shadow: inset 0 0 0 2px var(--mg-chat-wood-dark) !important;
}
/* v2.0.256 — Send button: was losing its white text colour on hover
 * because the site theme injects `button:hover { color: black
 * !important; background: red !important; border-color: red
 * !important }` (same attack vector the rename-btn pattern documents
 * at L138). The 2.0.253 version had `color: #fff` with no
 * !important — theme walked over it. Fix: kill border, paint the
 * 2px frame via inset box-shadow (theme can't target box-shadow),
 * lock down colour with both `color !important` and
 * `-webkit-text-fill-color` (Webkit autofill / theme combos
 * sometimes paint via the fill colour even when `color` is locked),
 * and explicitly bind paint properties on all interaction states
 * with .mg-farm-root prefix for specificity. The outer 2x2 drop
 * shadow that gives the NES pixel-art lift is folded into the same
 * box-shadow list. */
.mg-farm-chat-send {
    flex: 0 0 auto;
    border: 0 !important;
    outline: 0 !important;
    background: var(--mg-chat-sage) !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff;
    padding: 6px 14px;
    border-radius: 4px;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    box-shadow: inset 0 0 0 2px var(--mg-chat-sage-dark),
                2px 2px 0 var(--mg-chat-sage-dark);
    transition: transform 60ms ease, box-shadow 60ms ease, background 60ms ease;
}
.mg-farm-root .mg-farm-chat-send:hover,
.mg-farm-root .mg-farm-chat-send:focus,
.mg-farm-root .mg-farm-chat-send:focus-visible {
    background: var(--mg-chat-sage-dark) !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: inset 0 0 0 2px var(--mg-chat-sage-dark),
                2px 2px 0 var(--mg-chat-sage-dark) !important;
}
.mg-farm-root .mg-farm-chat-send:active {
    background: var(--mg-chat-sage-dark) !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff;
    border: 0 !important;
    outline: 0 !important;
    transform: translate(2px, 2px);
    box-shadow: inset 0 0 0 2px var(--mg-chat-sage-dark),
                0 0 0 var(--mg-chat-sage-dark) !important;
}

/* ---------- Speech bubble ----------
 *
 * Anchored as a child of .mg-farm-player or [data-mg-presence-uid=N]
 * (both are absolutely-positioned avatars). bottom: 100% + small gap
 * lifts the bubble cleanly above the head. transform: translateX
 * centers on the avatar's horizontal midpoint.
 *
 * Sprout-style pixel rounded rectangle done in pure CSS: cream fill,
 * wood border, classic comic "tail" via :after.
 */
.mg-farm-speech-bubble {
    position: absolute;
    left: 50%;
    /* v2.0.269 — back ABOVE the avatar (was below since v2.0.260).
     * User feedback: below was fine distance-wise but above feels more
     * natural for speech bubbles. Sprout Lands characters have more
     * empty pixel space at the top of their sprite cell than at the
     * bottom (head is centered ~60% up), so `bottom: 100%` floated
     * the bubble too far away. `margin-bottom: -10px` nudges it down
     * to sit visually close to the actual head rather than the cell
     * ceiling. Adjust if cell size changes. */
    bottom: 100%;
    transform: translateX(-50%);
    margin-bottom: -10px;
    /* v2.0.259 — `width: max-content` so the bubble sizes to its
     * text's intrinsic width (capped by max-width), NOT shrunk to
     * the parent .mg-farm-player's 1-cell containing block.
     *
     * Bug before: bubble's parent (the avatar) is `width: calc(1 *
     * var(--cell))` ≈ 16-32px. Absolute-positioned child with
     * `width: auto` runs shrink-to-fit: it uses the containing
     * block as the max width. With `word-break: break-word` every
     * CJK character is a valid break point, so the bubble collapsed
     * to ~1 character per line — a 14-char message rendered as a
     * tall vertical column. User: "bubble不應堆在一格" + screenshot.
     *
     * `max-width: 180px` didn't help — it's a cap, not a floor;
     * shrink-to-fit had already chosen something smaller.
     *
     * `width: max-content` says "size to the unwrapped text width".
     * Then min-width (36px) and max-width (180px) still clamp:
     * - short msgs: natural content width, ≥ 36px (legible bubble)
     * - long msgs: hit max-width 180px, wrap via word-break inside
     */
    width: max-content;
    min-width: 36px;
    max-width: 180px;
    padding: 6px 10px;
    background: var(--mg-chat-tile-bg, #fffaee);
    color: #2d2620;
    border: 2px solid var(--mg-chat-wood-dark, #6c4724);
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
    box-shadow: 2px 2px 0 rgba(108, 71, 36, 0.35);
    pointer-events: none;
    z-index: 35;
    word-break: break-word;
    white-space: pre-wrap;
    animation: mg-farm-bubble-in 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: opacity 320ms ease, transform 320ms ease;
}
.mg-farm-speech-bubble.is-fading {
    opacity: 0;
    /* v2.0.269 — fade UP (away from avatar below) now that bubble is
     * above again. Matches original pre-v2.0.260 direction. */
    transform: translateX(-50%) translateY(-6px);
}
.mg-farm-speech-bubble:after {
    /* v2.0.269 — tail points DOWN at the avatar below the bubble.
     * Reverted from v2.0.260's upward tail. */
    content: '';
    position: absolute;
    left: 50%;
    bottom: -6px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--mg-chat-wood-dark, #6c4724);
}
.mg-farm-speech-bubble:before {
    /* v2.0.269 — inner cream fill for the downward triangle. */
    content: '';
    position: absolute;
    left: 50%;
    bottom: -3px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--mg-chat-tile-bg, #fffaee);
    z-index: 1;
}
.mg-farm-speech-bubble--emoji {
    padding: 4px 4px;
    min-width: 0;
}
.mg-farm-speech-bubble__emoji {
    width: 28px;
    height: 28px;
    image-rendering: pixelated;
    display: block;
}

@keyframes mg-farm-bubble-in {
    /* v2.0.269 — bubble above avatar: starts slightly BELOW final
     * position (closer to the head) and rises up into place.
     * translateY(+6px) at 0% = "born near the head, floats up". */
    0%   { opacity: 0; transform: translateX(-50%) translateY(6px)  scale(0.7); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1);   }
}

/* ---------- Emoji burst (v2.0.269 — REMOVED) ----------
 * The floating head-top emoji pop was removed in 2.0.269. The speech
 * bubble already renders the emoji sprite inline; the burst was a
 * redundant second flash. CSS kept as stub so no orphan selector
 * errors if any cached JS still emits the class. */
.mg-farm-emoji-burst { display: none; }

/* =================================================================
 * v2.0.264 — Farm MP M3 mailbox Phase 2.
 *
 * Two surfaces:
 *   1. Badge overlay on the mailbox NPC sprite (when unread > 0)
 *      — small red pill positioned top-right of the decor.
 *   2. Modal styling — mail header, list, row, unread variant.
 *
 * Palette reuses --mg-chat-* tokens (cream + wood-dark + berry-red)
 * to stay visually consistent with chat panel / nametags / bubbles
 * (matched in 2.0.260-2.0.261).
 * ================================================================= */

/* Badge over the mail_npc decor — same shape language as
   .mg-farm-chat-badge (small red pill, white text, 2px ring). */
.mg-farm-mailbox-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--mg-chat-berry, #b85a4a);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    line-height: 18px;
    text-align: center;
    border: 2px solid var(--mg-chat-tile-bg, #f4e8c4);
    box-sizing: content-box;
    pointer-events: none;
    z-index: 5;
    /* Subtle pulse so a fresh badge catches the eye when the
       user lands in their farm. Looped (not just-on-change) so
       the cue stays gentle but persistent. */
    animation: mg-farm-mailbox-badge-pulse 2.4s ease-in-out infinite;
}
@keyframes mg-farm-mailbox-badge-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.12); }
}

/* ---------- Modal body ---------- */

.mg-farm-mail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 0 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px dashed var(--mg-chat-wood, #6a4a2c);
}
.mg-farm-mail-mark-all {
    flex: 0 0 auto;
    font-size: 11px;
    padding: 4px 10px;
}
.mg-farm-mail-empty {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--mg-chat-wood, #6a4a2c);
    line-height: 1.6;
}

.mg-farm-mail-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.mg-farm-mail-row {
    background: var(--mg-chat-tile-bg, #f4e8c4);
    border: 2px solid var(--mg-chat-wood, #6a4a2c);
    border-radius: 6px;
    padding: 8px 10px;
    cursor: default;
    transition: background 0.15s ease;
    /* Defence against site-theme button color overrides (same
       pattern as chat panel buttons — many themes target
       button:focus / button:hover with brand colours). */
    color: var(--mg-chat-wood, #6a4a2c);
}
.mg-farm-mail-row.is-unread {
    background: #fff8dc;
    border-color: var(--mg-chat-berry, #b85a4a);
    cursor: pointer;
}
.mg-farm-mail-row.is-unread:hover,
.mg-farm-mail-row.is-unread:focus {
    background: #fffce0;
    outline: none;
}

.mg-farm-mail-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 10px;
    opacity: 0.7;
}
.mg-farm-mail-time {
    font-variant-numeric: tabular-nums;
}
.mg-farm-mail-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mg-chat-berry, #b85a4a);
    box-shadow: 0 0 4px rgba(184,90,74,0.6);
}

.mg-farm-mail-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.mg-farm-mail-line {
    font-size: 12px;
    line-height: 1.5;
}
