/* ==========================================================================
   Teaberry landing page.

   Skinned with the game's own 9-slice art from /assets/ui and the Ari 9500
   pixel fonts, following the same rules as the in-game pixel skin (see the
   FRONT-END PIXEL SKIN block in styles.css):
     - assets are pre-scaled (_x2), so slice == border-width == intrinsic px
     - edge mode stretch, never round
     - every framed element carries BOTH `fill` and a solid body-colour
       background, so fractional-scale seams show frame colour
     - corners are cut with clip-path staircases traced from the art;
       border-radius stays 0 (a radius can never match the staircase)
     - slot frames do not use `fill`, so inset glows stay visible
     - no transform on hover: feedback is brightness and the pressed frame
   ========================================================================== */

@font-face {
    font-family: 'Ari9500';
    src: url('/assets/fonts/ari-w9500.ttf') format('truetype');
    font-weight: normal;
    font-display: block;
}
@font-face {
    font-family: 'Ari9500';
    src: url('/assets/fonts/ari-w9500-bold.ttf') format('truetype');
    font-weight: bold;
    font-display: block;
}
@font-face {
    font-family: 'Ari9500Display';
    src: url('/assets/fonts/ari-w9500-display.ttf') format('truetype');
    font-display: block;
}

:root {
    color-scheme: dark;

    /* The game's UI ramp (the art is drawn in these). */
    --outline: #222034;
    --win-bg: #252337;
    --btn-bg: #3b3a4c;
    --title-bg: #3b3a4c;
    --slot-bg: #1d1c2d;
    --line: #6b6883;
    --page-bg: #17162a;

    --text: #ecebf5;
    --text-2: #b9b6cc;
    --text-dim: #8a87a3;
    --gold: #ffe27a;
    --green: #2ecc71;
    --red: #ff7b6b;

    --frame-window: url('/assets/ui/ui_window_9slice_x2.png');
    --frame-title: url('/assets/ui/ui_titlebarstrip_9slice_x2.png');
    --frame-slot: url('/assets/ui/ui_slot_9slice_x2.png');
    --btn-up: url('/assets/ui/ui_button_up_x2.png');
    --btn-down: url('/assets/ui/ui_button_down_x2.png');

    /* Staircase corners, copied from styles.css (traced from the _x2 alpha). */
    --clip-window: polygon(
        10px 0, calc(100% - 10px) 0,
        calc(100% - 10px) 2px, calc(100% - 6px) 2px,
        calc(100% - 6px) 4px, calc(100% - 4px) 4px,
        calc(100% - 4px) 6px, calc(100% - 2px) 6px,
        calc(100% - 2px) 10px, 100% 10px,
        100% calc(100% - 10px),
        calc(100% - 2px) calc(100% - 10px), calc(100% - 2px) calc(100% - 6px),
        calc(100% - 4px) calc(100% - 6px), calc(100% - 4px) calc(100% - 4px),
        calc(100% - 6px) calc(100% - 4px), calc(100% - 6px) calc(100% - 2px),
        calc(100% - 10px) calc(100% - 2px), calc(100% - 10px) 100%,
        10px 100%,
        10px calc(100% - 2px), 6px calc(100% - 2px),
        6px calc(100% - 4px), 4px calc(100% - 4px),
        4px calc(100% - 6px), 2px calc(100% - 6px),
        2px calc(100% - 10px), 0 calc(100% - 10px),
        0 10px,
        2px 10px, 2px 6px, 4px 6px, 4px 4px,
        6px 4px, 6px 2px, 10px 2px
    );
    --clip-btn: polygon(
        4px 0, calc(100% - 4px) 0,
        calc(100% - 4px) 2px, calc(100% - 2px) 2px,
        calc(100% - 2px) 4px, 100% 4px,
        100% calc(100% - 4px),
        calc(100% - 2px) calc(100% - 4px), calc(100% - 2px) calc(100% - 2px),
        calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%,
        4px 100%,
        4px calc(100% - 2px), 2px calc(100% - 2px),
        2px calc(100% - 4px), 0 calc(100% - 4px),
        0 4px,
        2px 4px, 2px 2px, 4px 2px
    );
    --clip-slot: polygon(
        2px 0, calc(100% - 2px) 0,
        calc(100% - 2px) 2px, 100% 2px,
        100% calc(100% - 2px),
        calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) 100%,
        2px 100%,
        2px calc(100% - 2px), 0 calc(100% - 2px),
        0 2px,
        2px 2px
    );
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
    margin: 0;
    /* Everything written on the site can be selected and copied. */
    -webkit-user-select: text;
    user-select: text;
    background: var(--page-bg);
    color: var(--text);
    font: 16px/1.5 'Ari9500', ui-monospace, monospace;
    -webkit-font-smoothing: none;
    font-smooth: never;
}
img, .pixel { image-rendering: pixelated; }
a { color: var(--gold); }
b { font-weight: bold; color: var(--text); }
[hidden] { display: none !important; }

/* ── Frames ─────────────────────────────────────────────────────────────── */
.window {
    background: var(--win-bg);
    border: 12px solid transparent;
    border-image: var(--frame-window) 12 fill stretch;
    clip-path: var(--clip-window);
    min-width: 0;
}
.window-body { padding: 4px 6px 6px; }

.titlebar {
    margin: 0 0 12px;
    background: var(--title-bg);
    border: 6px solid transparent;
    border-image: var(--frame-title) 6 fill stretch;
    clip-path: var(--clip-slot);
    padding: 2px 8px;
    font: 20px/1.3 'Ari9500Display', 'Ari9500', monospace;
    letter-spacing: 1px;
    color: var(--text);
    text-shadow: 0 1px 0 var(--outline);
}

.slot {
    background: var(--slot-bg);
    border: 8px solid transparent;
    border-image: var(--frame-slot) 8 stretch;
    clip-path: var(--clip-slot);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.px-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--btn-bg);
    border: 10px solid transparent;
    border-image: var(--btn-up) 10 fill stretch;
    clip-path: var(--clip-btn);
    padding: 2px 12px;
    font: bold 16px/1.4 'Ari9500', monospace;
    letter-spacing: 1px;
    color: var(--text);
    text-decoration: none;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: filter 0.1s ease;
    white-space: nowrap;
}
.px-btn:hover { filter: brightness(1.15); }
.px-btn:active, .px-btn.active { border-image: var(--btn-down) 10 fill stretch; filter: none; }
.px-btn:focus-visible, .node:focus-visible, .line-tab:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: -8px;
}
.px-btn:disabled { filter: grayscale(0.6) brightness(0.6); cursor: default; }
.px-btn.primary {
    --btn-up: url('/assets/ui/ui_button_up_x2_shop.png');
    --btn-down: url('/assets/ui/ui_button_down_x2_shop.png');
    background: #5d4c2a;
    color: var(--gold);
}
.px-btn.small { font-size: 12px; padding: 0 8px; }
.px-btn.danger {
    --btn-up: url('/assets/ui/ui_button_up_x2_danger.png');
    --btn-down: url('/assets/ui/ui_button_down_x2_danger.png');
    background: #6b2a2a;
    color: #ffd2cc;
}
/* The Discord button: the game's bevel button recoloured blurple by
   tools/gen-landing-data.js (outline untouched), white label and mark. */
.px-btn.discord {
    --btn-up: url('img/btn-discord-up.png');
    --btn-down: url('img/btn-discord-down.png');
    background: #6772f3;
    color: #ffffff;
    letter-spacing: 2px;
    text-shadow: 0 1px 0 rgba(34, 32, 52, 0.6);
}
.discord-mark { width: 22px; height: 17px; fill: currentColor; flex-shrink: 0; }
.px-btn.icon-only { padding: 2px 4px; }
.px-btn.small .discord-mark { width: 18px; height: 14px; }
/* The X mark rides the plain bevel button: X's own colours are black and white. */
.x-mark { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }
.px-btn.small .x-mark { width: 14px; height: 14px; margin: 0 2px; }
/* Bluesky: plain bevel button, butterfly in Bluesky blue. */
.bsky-mark { width: 19px; height: 17px; fill: #3d9bff; flex-shrink: 0; }
.px-btn.small .bsky-mark { width: 16px; height: 14px; margin: 0 1px; }
/* Instagram: the same plain bevel button, camera glyph in Instagram pink. */
.ig-mark { width: 18px; height: 18px; fill: #ff5c93; flex-shrink: 0; }
.px-btn.small .ig-mark { width: 15px; height: 15px; margin: 0 1px; }
.px-btn.big { font-size: 24px; letter-spacing: 3px; padding: 8px 28px; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-2);
    white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; background: var(--text-dim); }
.pill.live { color: var(--text); }
.pill.live .dot { background: var(--green); box-shadow: 0 0 6px var(--green); }

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.px-input {
    width: 100%;
    background: var(--slot-bg);
    border: 8px solid transparent;
    border-image: var(--frame-slot) 8 stretch;
    clip-path: var(--clip-slot);
    padding: 0 4px;
    color: var(--text);
    font: 16px/1.8 'Ari9500', monospace;
    outline: none;
}
.px-input:focus { filter: brightness(1.25); }

/* ── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 16px;
    background: rgba(23, 22, 42, 0.92);
    border-bottom: 4px solid var(--outline);
    box-shadow: 0 2px 0 #3b3a4c;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-name { font: 20px/1 'Ari9500Display', 'Ari9500', monospace; letter-spacing: 2px; }
.berry {
    display: inline-block;
    width: 24px;
    height: 24px;
    background: url('img/teaberry.png') 0 0 / 24px 24px no-repeat;
    image-rendering: pixelated;
    flex-shrink: 0;
}
.nav { display: flex; gap: 20px; margin-right: auto; }
.nav a { color: var(--text-2); text-decoration: none; font-size: 16px; }
.nav a:hover { color: var(--gold); }
.topbar-right { display: flex; align-items: center; gap: 14px; }

/* ── Hero ───────────────────────────────────────────────────────────────── */
.hero {
    position: relative;
    /* The noon sky until landing.js paints the visitor's own hour. */
    background: linear-gradient(to bottom, rgb(61, 134, 212) 0%, rgb(61, 134, 212) 38%, rgb(168, 210, 240) 92%);
    /* The grass is 64px tall; the extra keeps the account window off it. */
    padding: 48px 16px 104px;
    overflow: hidden;
}

/* ── The sky (visual-effects.js, drawn the way the title screen draws it) ── */
.sky, .sky-tint { position: absolute; inset: 0; pointer-events: none; }
.sky { overflow: hidden; }
.sky-stars { position: absolute; top: 0; left: 0; opacity: 0; transition: opacity 2.5s linear; }
.star-layer { position: absolute; top: 0; left: 0; width: 1px; height: 1px; background: transparent; }
.star-far { animation: twinkle-b 6.8s ease-in-out infinite; }
.star-near { width: 2px; height: 2px; animation: twinkle-a 4.5s ease-in-out infinite; }
@keyframes twinkle-a { 0%, 100% { opacity: 1; } 50% { opacity: 0.42; } }
@keyframes twinkle-b { 0%, 100% { opacity: 0.8; } 50% { opacity: 0.28; } }
/* Sun 22px art at 3x, moon at 2x; both centred on their arc position. */
.sky-sun, .sky-moon { position: absolute; transform: translate(-50%, -50%); image-rendering: pixelated; }
.sky-sun { width: 66px; height: 66px; filter: drop-shadow(0 0 18px rgba(255, 190, 90, 0.7)); }
.sky-moon {
    width: 44px; height: 44px;
    filter: drop-shadow(0 0 4px rgba(235, 242, 255, 1)) drop-shadow(0 0 16px rgba(210, 225, 255, 0.85))
            drop-shadow(0 0 38px rgba(190, 210, 255, 0.5)) drop-shadow(0 0 65px rgba(170, 195, 255, 0.22));
}
/* The bluesky backdrop (128x256) at 3x, set so its hill line sits just above the grass. */
.sky-hills {
    position: absolute;
    left: 0; right: 0;
    bottom: -156px;
    height: 768px;
    background: url('img/sky/hills.png') 0 100% / 384px 768px repeat-x;
    image-rendering: pixelated;
}
.sky-clouds { position: absolute; inset: 0; }
.cloud {
    position: absolute;
    left: 0;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    image-rendering: pixelated;
    animation: cloud-drift linear infinite;
    will-change: transform;
}
@keyframes cloud-drift {
    from { transform: translateX(-460px); }
    to   { transform: translateX(var(--sky-w, 1400px)); }
}
/* The scene tint: the game's #fx-daynight gradient, over the sky, hills, clouds
   and grass, under everything you read or click. */
.sky-tint { z-index: 1; }
.snail {
    position: absolute;
    left: -48px;
    bottom: 50px;
    width: 48px;
    height: 48px;
    background: url('img/sky/snail.png') 0 0 / 144px 48px no-repeat;
    image-rendering: pixelated;
    animation: snail-walk 0.55s steps(3) infinite;
    z-index: 2; /* above the tint, like the title-screen snail */
    display: none;
}
@keyframes snail-walk { from { background-position-x: 0; } to { background-position-x: -144px; } }

/* ── Halloween (landing.js setHalloween) ─────────────────────────────────────
   Dressed the way the game's title screen is: the game's own autumn recolour
   of the grass and far hills (tools/gen-landing-data.js), bats across the sky,
   the skeleton snail, and one lit jack-o-lantern on the grass. Absolute paths:
   a url() in a custom property must not depend on which sheet reads it. */
body.halloween .sky-hills { background-image: url('/site/img/halloween/hills.png'); }
body.halloween .snail { background-image: url('/site/img/halloween/snail.png'); }
.hw-bats { position: absolute; inset: 0; pointer-events: none; display: none; }
body.halloween .hw-bats { display: block; }
.hw-bat {
    position: absolute;
    left: 0;
    width: 36px;
    height: 21px;
    background: url('/site/img/halloween/bat.png') 0 0 / 72px 21px no-repeat;
    image-rendering: pixelated;
    animation: hw-bat-fly linear infinite, hw-bat-flap 0.28s steps(1, end) infinite;
}
.hw-bat.rtl { animation-name: hw-bat-fly-back, hw-bat-flap; }
@keyframes hw-bat-fly {
    0%   { transform: translate(-60px, 0); }
    25%  { transform: translate(25vw, 30px); }
    50%  { transform: translate(50vw, -10px); }
    75%  { transform: translate(75vw, 25px); }
    100% { transform: translate(calc(100vw + 60px), 0); }
}
@keyframes hw-bat-fly-back {
    0%   { transform: translate(calc(100vw + 60px), 10px) scaleX(-1); }
    50%  { transform: translate(50vw, 40px) scaleX(-1); }
    100% { transform: translate(-60px, 0) scaleX(-1); }
}
@keyframes hw-bat-flap { 0% { background-position-x: 0; } 50% { background-position-x: -36px; } }
/* The lit lantern's idle frame (18x18) at 3x, its anchor row on the grass line. */
.hw-lantern {
    position: absolute;
    right: 9%;
    bottom: 50px;
    width: 54px;
    height: 54px;
    background: url('/site/img/halloween/lantern.png') 0 0 / 270px 54px no-repeat;
    image-rendering: pixelated;
    z-index: 2;
    display: none;
}
body.halloween .hw-lantern { display: block; }
.hw-lantern-glow {
    position: absolute;
    inset: -30px;
    z-index: -1;
    background: radial-gradient(circle, rgba(255, 170, 60, 0.45) 0%, rgba(255, 120, 30, 0.15) 40%, transparent 70%);
    animation: hw-flicker 2.6s ease-in-out infinite;
}
@keyframes hw-flicker { 0%, 100% { opacity: 0.85; } 40% { opacity: 1; } 55% { opacity: 0.7; } 70% { opacity: 0.95; } }
.hw-chip {
    display: inline-block;
    margin: 14px 0 0;
    padding: 0 6px;
    color: #ffb347;
    text-shadow: 0 1px 0 var(--outline);
}
.hw-chip b { color: var(--gold); }
@media (prefers-reduced-motion: reduce) {
    .hw-bat, .hw-lantern-glow { animation: none; }
    .hw-bats { display: none !important; }
}
@media (max-width: 720px) { .hw-lantern { right: 4%; } }
@media (prefers-reduced-motion: reduce) {
    .cloud, .star-layer, .snail { animation: none; }
}
.hero-inner {
    position: relative;
    z-index: 2;
    max-width: 1120px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 40px;
    align-items: center;
}
/* The logo, the pitch and the buttons as one centred column, so they read as
   one block beside the account window rather than a ragged left edge. */
.hero-copy { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 22px; }

/* The animated title card: the in-game sheet at 3x. Frames are 176x42 and the
   game plays the first 15 (spriteData.titleCard); the sheet itself is 2816px
   wide, and background-size must use the real width or every frame squashes. */
.title-card {
    --scale: 3;
    --fw: 176px;
    --fh: 42px;
    --frames: 15;
    --sheet-w: 2816px;
    margin: 0;
    width: calc(var(--fw) * var(--scale));
    height: calc(var(--fh) * var(--scale));
    background: url('img/title-card.png') 0 0 no-repeat;
    background-size: calc(var(--sheet-w) * var(--scale)) calc(var(--fh) * var(--scale));
    image-rendering: pixelated;
    /* 15 frames at ~75ms each. The game advances a frame every 8 animation
       frames, which is this on a 120Hz screen; 133ms per frame read as sluggish. */
    animation: title-card 1.1s steps(15) infinite;
}
@keyframes title-card {
    to { background-position: calc(var(--fw) * var(--frames) * var(--scale) * -1) 0; }
}
@media (prefers-reduced-motion: reduce) { .title-card { animation: none; } }

.tagline {
    margin: 0;
    max-width: 38ch;
    text-wrap: balance;
    font-size: 20px;
    color: var(--text);
    text-shadow: 0 2px 0 var(--outline);
}
.hero-cta { display: grid; gap: 10px; width: min(440px, 100%); }
.hero-cta .px-btn { width: 100%; }
.hero-cta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero-cta-row .px-btn { font-size: 14px; padding-left: 6px; padding-right: 6px; }
.hero-download {
    justify-self: center;
    font: 13px/1.4 'Ari9500', monospace;
    letter-spacing: 1px;
    color: var(--text);
    text-shadow: 0 1px 0 var(--outline);
}
.hero-download:hover { color: var(--gold); }
.hero-download[hidden] { display: none; }
/* The grass surface: the game's groundGrass tile at 4x. The earth under it is
   the .underground canvas, which starts on the same 64px grid. */
.grass {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 64px;
    background: var(--ground-top, url('img/ground-top.png')) 0 0 / 64px 64px repeat-x;
    image-rendering: pixelated;
}

/* ── The earth ──────────────────────────────────────────────────────────── */
.underground {
    position: relative;
    /* Until the canvas paints: the deep, darkened earth. The top 2px stay clear
       and the box tucks 1px under the grass, so when the hero ends on a
       fractional pixel no dark hairline shows between grass and earth. Above
       the hero's layers too (sky tint 1, snail and copy 2): the tint's darkest
       row otherwise lands on the earth's first row as that hairline. */
    margin-top: -1px;
    z-index: 3;
    background: linear-gradient(transparent 2px, #120c09 2px);
    overflow: hidden;
}
#earth {
    position: absolute;
    left: 0;
    top: 0;
    image-rendering: pixelated;
    pointer-events: none;
}
.content, .footer { position: relative; z-index: 1; }

/* ── Account window ─────────────────────────────────────────────────────── */
.account-window { width: 100%; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs .tab { flex: 1; font-size: 12px; }
.tabs.wrap { flex-wrap: wrap; }
.tabs.wrap .tab { flex: 0 0 auto; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.check input { accent-color: #c89c4a; }
.form-msg { min-height: 1.5em; margin: 10px 0 0; font-size: 12px; color: var(--red); }
.form-msg.ok { color: var(--green); }
.fine { margin: 8px 0 0; font-size: 12px; color: var(--text-dim); }

/* The Account window (landing.js openAccountWindow), in the inspect modal. */
.acct { display: grid; gap: 22px; }
.acct-section { display: grid; gap: 8px; justify-items: start; }
.acct-section > .fine { margin: 0; }
.acct-heading { margin: 0; font: 18px/1.3 'Ari9500Display', 'Ari9500', monospace; color: var(--gold); }
.acct-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; width: 100%; }
.acct-label { font-size: 12px; color: var(--text-dim); padding-top: 2px; }
.acct-value { color: var(--text); overflow-wrap: anywhere; }
.acct-form { width: min(360px, 100%); }
.acct-form .form-msg { margin: 0; }
.acct-danger .acct-heading { color: var(--red); }
@media (max-width: 560px) { .acct-row { grid-template-columns: minmax(0, 1fr); gap: 0; } }

/* Launch list sign-up (signup.js), on the home and press pages. */
.signup-form { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.signup-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.signup-form .form-msg { margin: 0; }
.signup-form .fine { margin: 0; }
/* The honeypot: off-screen rather than display:none, which some bots skip. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 560px) { .signup-row { grid-template-columns: minmax(0, 1fr); } }

/* Your heroes: little character-select cards, each hero idling on a strip of
   grass under the dusk sky. Click one to inspect it. */
.heroes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.hero-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    background: var(--slot-bg);
    border: 8px solid transparent;
    border-image: var(--frame-slot) 8 stretch;
    clip-path: var(--clip-slot);
    color: var(--text);
    font: 12px/1.3 'Ari9500', monospace;
    text-align: center;
    cursor: pointer;
    transition: filter 0.1s ease;
}
.hero-card:hover { filter: brightness(1.15); }
.hero-card:focus-visible { outline: 2px solid var(--gold); outline-offset: -6px; }
.hero-card .name { font-weight: bold; font-size: 14px; color: var(--text); overflow-wrap: anywhere; margin-top: 4px; }
.hero-card .meta { color: var(--text-2); padding-bottom: 4px; }

/* A patch of sky with grass along the bottom, for a character to stand on. */
.stage {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    background: linear-gradient(180deg, #2a3550 0%, #7f93b8 100%);
    overflow: hidden;
    --grass: 32px;
    padding-bottom: calc(var(--grass) - 6px);
}
.stage::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: var(--grass);
    background: var(--ground-top, url('img/ground-top.png')) 0 0 / var(--grass) var(--grass) repeat-x;
    image-rendering: pixelated;
}
.stage .sprite { position: relative; z-index: 1; image-rendering: pixelated; display: block; }
.hero-card .stage { --grass: 32px; height: 132px; padding-bottom: 26px; }

/* ── Sprite icons ───────────────────────────────────────────────────────── */
/* Cells from the class and skill sheets, scaled by whole numbers only. */
.icon {
    --s: 3;
    display: block;
    width: calc(16px * var(--s));
    height: calc(16px * var(--s));
    background-repeat: no-repeat;
    image-rendering: pixelated;
    flex-shrink: 0;
}
/* Sheet sizes come from data/classes.json (landing.js sets the variables), so a
   sheet that grows (a new class column) never squeezes every icon. */
.icon.class { background-image: url('img/class-icons.png'); background-size: calc(var(--class-sheet-w, 112px) * var(--s)) calc(var(--class-sheet-h, 80px) * var(--s)); }
.icon.skill { background-image: url('img/skill-icons.png'); background-size: calc(var(--skill-sheet-w, 256px) * var(--s)) calc(var(--skill-sheet-h, 144px) * var(--s)); }
.icon.x2 { --s: 2; }
.icon.x4 { --s: 4; }

/* ── Content ────────────────────────────────────────────────────────────── */
.content {
    max-width: 1120px;
    margin: 0 auto;
    padding: 40px 16px 24px;
    display: grid;
    gap: 28px;
}
.split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 28px; align-items: start; }
.intro { margin: 0 0 16px; color: var(--text-2); max-width: 70ch; }

/* Updates */
.updates { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.update-date { font-size: 12px; color: var(--text-dim); }
.update-title { margin: 2px 0 6px; font: 18px/1.3 'Ari9500Display', 'Ari9500', monospace; color: var(--gold); }
.update-items { margin: 0; padding-left: 18px; color: var(--text-2); }
.update-items li { margin: 3px 0; }
.update-items li::marker { color: var(--line); }
#updates-more { margin-top: 16px; }

/* Rankings */
.ranks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rank-row {
    display: grid;
    grid-template-columns: 32px 40px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 2px 4px;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.rank-row:hover { background: rgba(255, 255, 255, 0.05); }
.rank-row:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
/* The head-and-shoulders portrait, the same crop the in-game rankings use. */
.portrait {
    width: 40px;
    height: 40px;
    background: linear-gradient(180deg, #2a3550 0%, #7f93b8 100%);
    border: 2px solid var(--outline);
    image-rendering: pixelated;
}
.rank-row .pos { text-align: center; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.rank-row .pos.top { font-size: 20px; line-height: 1; }
.rank-row .who { min-width: 0; }
.rank-row .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.rank-row .job { display: block; font-size: 12px; color: var(--text-dim); }
.rank-row .val { color: var(--gold); font-variant-numeric: tabular-nums; text-align: right; }

/* Class tree */
.line-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.line-tab { font-size: 12px; padding: 0 10px 0 4px; }
.class-view { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }

/* Tree: node, stem, then either a single column or two branches hung from a
   bar. Connectors are 4px pixel lines in the frame's mid tone. */
.tree { display: flex; flex-direction: column; align-items: center; }
.stem { width: 4px; height: 20px; background: var(--line); flex-shrink: 0; }
.branches { position: relative; display: flex; gap: 16px; width: 100%; padding-top: 20px; }
.branches::before {
    /* The bar from one branch's centre line to the other's. Each branch is
       (100% - 16px) / 2 wide, so its centre sits at 25% - 4px from its edge
       of the row; the extra 2px covers half the 4px stem. */
    content: '';
    position: absolute;
    top: 0;
    left: calc(25% - 6px);
    right: calc(25% - 6px);
    height: 4px;
    background: var(--line);
}
.branch { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.branch::before {
    content: '';
    position: absolute;
    top: -20px;
    left: calc(50% - 2px);
    width: 4px;
    height: 20px;
    background: var(--line);
}

.node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 140px;
    max-width: 100%;
    padding: 4px 2px;
    background: var(--slot-bg);
    border: 8px solid transparent;
    border-image: var(--frame-slot) 8 stretch;
    clip-path: var(--clip-slot);
    color: var(--text);
    font: 12px/1.3 'Ari9500', monospace;
    cursor: pointer;
    transition: filter 0.1s ease;
}
.node:hover { filter: brightness(1.2); }
.node.selected { box-shadow: inset 0 0 22px 3px rgba(241, 196, 15, 0.5), inset 0 0 0 2px rgba(241, 196, 15, 0.35); }
.node .node-title { font-weight: bold; font-size: 14px; text-align: center; }
.node .node-lv { color: var(--text-dim); }
.node.third .node-lv { color: var(--gold); }

.job-detail { min-width: 0; }
.job-head { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.job-head h3 { margin: 0; font: 24px/1.2 'Ari9500Display', 'Ari9500', monospace; }
.job-head .job-meta { font-size: 12px; color: var(--text-dim); }
.job-desc { margin: 0 0 14px; color: var(--text-2); }
.resource { margin: 0 0 16px; padding: 6px 10px; font-size: 14px; color: var(--text-2); }
.resource b { color: var(--gold); }
.skills { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.skill { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; align-items: start; }
.skill .slot { padding: 0; width: 48px; height: 48px; display: grid; place-items: center; }
.skill-name { font-weight: bold; }
.skill-meta { font-size: 12px; color: var(--text-dim); }
.skill-desc { margin: 2px 0 0; font-size: 14px; color: var(--text-2); }
.el-fire { color: #ff9a5c; } .el-frost { color: #8fd8ff; } .el-lightning { color: #fff07a; }
.el-poison { color: #9be36b; } .el-holy { color: #ffe9a8; } .el-dark { color: #c49bff; } .el-blood { color: #ff6b7d; }

/* Footer */
.footer {
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    padding: 24px 16px 48px;
    font-size: 12px; color: var(--text-dim);
}
.footer-social { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.footer-line { display: inline-flex; align-items: center; gap: 10px; }
.footer-line a { color: var(--text-2); }

/* ── Inspect window ─────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 16px;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 9, 20, 0.72); }
.modal-window {
    position: relative;
    width: min(760px, 100%);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    animation: modal-in 0.14s ease-out;
}
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal-window { animation: none; } }
.modal-window .window-body { overflow-y: auto; min-height: 0; }
.modal-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    padding: 0 0 0 8px;
}
.modal-title h2 { margin: 0; font: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The game's X: 36x36 up frame, pressed frame beside it, swapped instantly. */
.close-btn {
    width: 36px;
    height: 36px;
    margin: -6px -6px -6px 0;
    padding: 0;
    border: 0;
    background: url('/assets/ui/ui_xbutton_x3.png') 0 0 no-repeat;
    cursor: pointer;
    flex-shrink: 0;
}
.close-btn:hover { filter: brightness(1.2); }
.close-btn:active { background-position: -36px 0; filter: none; }
.close-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: -4px; }

.inspect { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.inspect .stage { height: 190px; --grass: 32px; padding-bottom: 26px; box-shadow: inset 0 0 0 4px var(--outline); }
.inspect .stage .badge { position: absolute; top: 8px; left: 8px; z-index: 2; }
.inspect-name { margin: 0; font: 24px/1.2 'Ari9500Display', 'Ari9500', monospace; overflow-wrap: anywhere; }
.inspect-sub { margin: 2px 0 12px; color: var(--text-2); }
.inspect-sub .lv { color: var(--gold); }

.bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.bar {
    height: 14px;
    background: var(--outline);
    clip-path: polygon(3px 0, calc(100% - 3px) 0, calc(100% - 3px) 1px, calc(100% - 2px) 1px, calc(100% - 2px) 2px, calc(100% - 1px) 2px, calc(100% - 1px) 3px, 100% 3px, 100% calc(100% - 3px), calc(100% - 1px) calc(100% - 3px), calc(100% - 1px) calc(100% - 2px), calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) calc(100% - 1px), calc(100% - 3px) calc(100% - 1px), calc(100% - 3px) 100%, 3px 100%, 3px calc(100% - 1px), 2px calc(100% - 1px), 2px calc(100% - 2px), 1px calc(100% - 2px), 1px calc(100% - 3px), 0 calc(100% - 3px), 0 3px, 1px 3px, 1px 2px, 2px 2px, 2px 1px, 3px 1px);
    margin-bottom: 14px;
}
/* The game's pill fill (ui_bar_exp.png, slice 3), like the HUD's EXP bar. */
.bar-fill {
    height: 100%;
    min-width: 6px;
    background: #ff9213;
    border: 3px solid transparent;
    border-image: url('/assets/ui/ui_bar_exp.png') 3 fill stretch;
}

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.stat-box { text-align: center; padding: 2px 0; }
.stat-box .k { display: block; font-size: 12px; color: var(--text-dim); }
.stat-box .v { display: block; font-weight: bold; font-variant-numeric: tabular-nums; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; font-size: 14px; }
.facts li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 2px solid rgba(107, 104, 131, 0.35); padding: 2px 0; }
.facts .k { color: var(--text-dim); }
.facts .v { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.inspect-note { margin: 10px 0 0; font-size: 12px; color: var(--text-dim); }

.gear-title { margin: 18px 0 8px; font: 16px/1.2 'Ari9500Display', 'Ari9500', monospace; color: var(--text-2); letter-spacing: 1px; }
.gear { display: grid; grid-template-columns: repeat(auto-fill, 48px); gap: 6px; }
.gear-slot {
    position: relative;
    width: 48px;
    height: 48px;
    padding: 0;
    display: grid;
    place-items: center;
    background: var(--slot-bg);
    border: 8px solid transparent;
    border-image: var(--frame-slot) 8 stretch;
    clip-path: var(--clip-slot);
    cursor: pointer;
    transition: filter 0.1s ease;
}
.gear-slot:hover { filter: brightness(1.25); }
.gear-slot.empty { cursor: default; opacity: 0.55; }
.gear-slot.empty:hover { filter: none; }
.gear-slot.selected { box-shadow: inset 0 0 12px 2px rgba(241, 196, 15, 0.55); }
.gear-slot:focus-visible { outline: 2px solid var(--gold); outline-offset: -6px; }
.gear-slot img { width: 32px; height: 32px; image-rendering: pixelated; display: block; }
.gear-slot .slot-name { font-size: 10px; color: var(--text-dim); line-height: 1; text-transform: uppercase; }
.gear-slot .enh { position: absolute; right: -4px; bottom: -6px; font-size: 10px; color: var(--gold); text-shadow: 0 1px 0 var(--outline); }
/* Rarity is an inset glow inside the slot frame, as in the inventory. */
.gear-slot.r-rare { box-shadow: inset 0 0 8px 1px rgba(0, 170, 255, 0.55); }
.gear-slot.r-epic { box-shadow: inset 0 0 8px 1px rgba(155, 89, 182, 0.7); }
.gear-slot.r-legendary { box-shadow: inset 0 0 8px 1px rgba(243, 156, 18, 0.7); }
.gear-slot.r-mythic { box-shadow: inset 0 0 8px 1px rgba(0, 229, 204, 0.65); }
.gear-slot.r-prismatic { box-shadow: inset 0 0 8px 1px rgba(240, 234, 255, 0.75); }
/* Prismatic cycles the game's six rainbow colours every 2s (prismaticText and
   the --px-beat-prism slot glow in styles.css). A CSS animation is fine here:
   an inspect window holds a couple of dozen slots, not the game's whole bag. */
.gear-slot.r-prismatic:not(.selected) { animation: prismatic-glow 2s linear infinite; }
@keyframes prismatic-glow {
    0%, 100% { box-shadow: inset 0 0 8px 2px rgba(255, 100, 100, 0.7); }
    16.67% { box-shadow: inset 0 0 8px 2px rgba(255, 200, 50, 0.7); }
    33.33% { box-shadow: inset 0 0 8px 2px rgba(100, 255, 100, 0.7); }
    50% { box-shadow: inset 0 0 8px 2px rgba(100, 200, 255, 0.7); }
    66.67% { box-shadow: inset 0 0 8px 2px rgba(180, 100, 255, 0.7); }
    83.33% { box-shadow: inset 0 0 8px 2px rgba(255, 100, 200, 0.7); }
}

.item-card { margin-top: 10px; padding: 6px 10px; font-size: 14px; min-height: 52px; }
.item-card .iname { font-weight: bold; }
.item-card .imeta { font-size: 12px; color: var(--text-dim); }
.item-card .istats { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--text-2); }
.rarity-common { color: #ffffff; } .rarity-rare { color: #00aaff; } .rarity-epic { color: #c07ee0; }
.rarity-legendary { color: #f39c12; } .rarity-mythic { color: #00e5cc; } .rarity-prismatic { color: #f0eaff; animation: prismatic-text 2s linear infinite; }
.rarity-celestial { color: #ffe39a; animation: celestial-text 3s ease-in-out infinite; }
.gear-slot.r-celestial { box-shadow: inset 0 0 8px 2px rgba(255, 205, 110, 0.75); }
@keyframes celestial-text {
    0%, 100% { color: #a8c6ff; text-shadow: 0 0 10px rgba(120, 160, 255, 0.6); }
    50% { color: #ffe39a; text-shadow: 0 0 12px rgba(255, 205, 110, 0.75); }
}
@keyframes prismatic-text {
    0%, 100% { color: #ff6464; text-shadow: 0 0 10px rgba(255, 100, 100, 0.6); }
    16.67% { color: #ffc832; text-shadow: 0 0 10px rgba(255, 200, 50, 0.6); }
    33.33% { color: #64ff64; text-shadow: 0 0 10px rgba(100, 255, 100, 0.6); }
    50% { color: #64c8ff; text-shadow: 0 0 10px rgba(100, 200, 255, 0.6); }
    66.67% { color: #b464ff; text-shadow: 0 0 10px rgba(180, 100, 255, 0.6); }
    83.33% { color: #ff64c8; text-shadow: 0 0 10px rgba(255, 100, 200, 0.6); }
}
/* Held still, prismatic still reads as a rainbow rather than white. */
@media (prefers-reduced-motion: reduce) {
    .gear-slot.r-prismatic:not(.selected), .rarity-prismatic { animation: none; }
    .gear-slot.r-prismatic:not(.selected) { box-shadow: inset 0 0 8px 2px rgba(180, 100, 255, 0.7); }
    .rarity-prismatic {
        background: linear-gradient(90deg, #ff6464, #ffc832, #64ff64, #64c8ff, #b464ff, #ff64c8);
        -webkit-background-clip: text; background-clip: text; color: transparent;
    }
}

/* ── Narrow screens ─────────────────────────────────────────────────────── */
@media (max-width: 980px) {
    .hero-inner { grid-template-columns: minmax(0, 1fr); }
    .account-window { max-width: 420px; margin: 0 auto; }
    .split { grid-template-columns: minmax(0, 1fr); }
    .class-view { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
    .inspect { grid-template-columns: minmax(0, 1fr); }
    .facts { grid-template-columns: minmax(0, 1fr); }
    .topbar-right { margin-left: auto; }
    .title-card { --scale: 2; }
    .skills { grid-template-columns: minmax(0, 1fr); }
    .px-btn.big { font-size: 20px; padding: 6px 20px; }
}
@media (max-width: 480px) {
    .online-pill { display: none; }
    .brand-name { font-size: 16px; }
    .topbar { gap: 10px; }
    .topbar-right { gap: 8px; }
}
@media (max-width: 380px) {
    .node { width: 100%; }
}

/* Skill numbers: level 1, then max level picked out in gold. */
.skills-legend { margin: 0 0 10px; font-size: 12px; color: var(--text-dim); }
.lv-range { white-space: nowrap; }
.lv-range .lv1 { color: var(--text); }
.lv-range .arrow { color: var(--text-dim); }
.lv-range .lvmax { color: var(--gold); font-weight: bold; }
.desc-line { display: block; }
.desc-line .lv1 { color: var(--text-dim); }
.desc-line .lvmax { color: var(--gold); }
.skill-stats { margin-top: 3px; font-size: 12px; color: var(--text-dim); }
.skill-stats b { color: var(--text); font-weight: normal; }

/* Signed in: the sign-in window steps aside and the pitch takes the hero. */
.hero-inner.solo { grid-template-columns: minmax(0, 1fr); }

/* Only one Play in view: the top bar's waits until PLAY NOW scrolls away. */
.topbar-play { transition: opacity 0.15s ease, visibility 0.15s; }
.topbar-play.tucked { opacity: 0; visibility: hidden; }

/* Your heroes: a titlebar carrying who you are and Sign Out, then the cards. */
.heroes-titlebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.heroes-titlebar h2 { margin: 0 auto 0 0; font: inherit; }
.heroes-who { font: 12px/1.3 'Ari9500', monospace; color: var(--text-2); letter-spacing: 0; }
.heroes-who b { color: var(--text); }
.heroes-hint { margin: 0 0 10px; }

/* Share a hero: the link, and a button that copies it. */
.share-row { display: flex; align-items: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.share-url { width: auto; flex: 1 1 220px; min-width: 0; font-size: 14px; cursor: text; }
.share-status { flex-basis: 100%; min-height: 1.3em; font-size: 12px; color: var(--text-dim); }
.share-status.ok { color: var(--green); }

/* ── Live now ─────────────────────────────────────────────────────────────── */
.stack { display: grid; gap: 28px; align-content: start; min-width: 0; }
.live-titlebar { display: flex; align-items: center; gap: 10px; }
.live-event.ev-halloween .live-event-title { color: #ffb347; }
.live-dot {
    width: 8px; height: 8px; flex-shrink: 0;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: live-pulse 1.6s steps(2) infinite;
}
@keyframes live-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.live-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.live-count { font: 40px/1 'Ari9500Display', 'Ari9500', monospace; color: var(--gold); text-shadow: 0 2px 0 var(--outline); font-variant-numeric: tabular-nums; }
.live-count-label { font-size: 14px; color: var(--text); }
.live-count-label .fine { margin: 0; }
.live-event { padding: 4px 8px; margin-top: 8px; font-size: 14px; color: var(--text-2); }
.live-event-title { font: 16px/1.3 'Ari9500Display', 'Ari9500', monospace; color: var(--text); letter-spacing: 1px; }
.live-event b { color: var(--text); }
.live-line { margin-top: 2px; }
.live-event .countdown { color: var(--gold); font-variant-numeric: tabular-nums; }
.live-bar { margin: 6px 0 2px; height: 12px; }
.live-bar.hp .bar-fill { background: #cb1e1e; border-image: url('/assets/ui/ui_bar_hp.png') 3 fill stretch; }
.ev-boss .live-event-title { color: #ff8f7a; }
.ev-exp .live-event-title, .ev-surge .live-event-title { color: var(--gold); }
.ev-fish .live-event-title { color: #8fd8ff; }
.ev-goal .live-event-title { color: #9be36b; }
.live-quiet { margin: 4px 0 0; }

/* ── Development updates from Discord: one collapsible post each ─────────── */
.update-post > summary { cursor: pointer; list-style: none; display: grid; gap: 2px; }
.update-post > summary::-webkit-details-marker { display: none; }
.update-post > summary .update-title::before { content: '\25B6  '; font-size: 12px; color: var(--text-dim); }
.update-post[open] > summary .update-title::before { content: '\25BC  '; }
.update-post .update-title { margin: 2px 0 0; font: 18px/1.3 'Ari9500Display', 'Ari9500', monospace; color: var(--gold); }
.update-intro { color: var(--text); }
.update-heading { margin: 14px 0 4px; font: 16px/1.3 'Ari9500Display', 'Ari9500', monospace; color: var(--text); letter-spacing: 1px; }
.update-para { margin: 4px 0; color: var(--text-2); }
.update-post b { color: var(--text); }
.update-post code { font-family: inherit; color: var(--gold); }

/* ── Phones ──────────────────────────────────────────────────────────────────
   One column, with the things worth checking on a phone first: your heroes,
   then what is live, then news and the boards. The section links stay
   reachable as a scrolling strip under the top bar. */
@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; row-gap: 4px; padding: 6px 12px 4px; }
    .nav {
        order: 3;
        flex: 1 0 100%;
        margin: 0 -12px;
        padding: 2px 12px 4px;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav a {
        flex: 0 0 auto;
        padding: 4px 12px;
        font-size: 14px;
        color: var(--text);
        background: var(--btn-bg);
        border: 2px solid var(--outline);
    }
    html { scroll-padding-top: 104px; }

    .hero { padding: 28px 12px 96px; }
    .content { padding: 28px 12px 16px; gap: 20px; }
    .window-body { padding: 2px 2px 4px; }
    .titlebar { font-size: 17px; padding: 2px 6px; }

    /* Live first, then news, then the rankings. */
    /* minmax(0, 1fr): the sideways-scrolling tab strips below must not widen the page. */
    .content { grid-template-columns: minmax(0, 1fr); }
    .split { display: flex; flex-direction: column; align-items: stretch; gap: 20px; }
    .split > * , .split > .stack > * { min-width: 0; }
    .split > .stack { display: contents; }
    #live { order: 1; }
    #news { order: 2; }
    #rankings { order: 3; }

    /* Your heroes: two to a row, name and Sign Out on one line. */
    .heroes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .hero-card .stage { height: 112px; }
    .heroes-titlebar { flex-wrap: nowrap; }
    .heroes-who { display: none; }

    /* Tabs that scroll sideways instead of stacking three rows deep. */
    #rank-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
    #rank-tabs::-webkit-scrollbar { display: none; }
    #rank-tabs .tab { flex: 0 0 auto; }
    /* The six class lines as a row of icons; the tree below names the job. */
    .line-tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
    .line-tab { padding: 0; min-width: 0; }
    .line-tab span:not(.icon) { display: none; }

    .rank-row { grid-template-columns: 26px 40px minmax(0, 1fr) auto; gap: 8px; }
    .update-title, .update-post .update-title { font-size: 16px; }
    .live-count { font-size: 34px; }

    /* The inspect window takes the whole screen. */
    /* One fixed-size grid cell: an auto row would grow to the window's content,
       and the body would never get a height to scroll inside. */
    .modal { padding: 0; place-items: stretch; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
    .modal-window { width: 100%; max-height: 100%; height: 100%; }
    .inspect .stage { height: 160px; }
    .gear { grid-template-columns: repeat(auto-fill, 44px); gap: 4px; }
    .gear-slot { width: 44px; height: 44px; }
    .gear-slot img { width: 24px; height: 24px; }
    .share-row .px-btn { flex: 1 1 auto; }
}

/* ── Bestiary ───────────────────────────────────────────────────────────── */
/* One atlas row per monster (img/monsters.png), idle frames left to right,
   stepped through in CSS. --s is a whole-number scale; sheet units elsewhere. */
.mon-sprite {
    position: relative;
    z-index: 1;
    display: block;
    flex-shrink: 0;
    width: calc(var(--w) * var(--s) * 1px);
    height: calc(var(--h) * var(--s) * 1px);
    background: url('img/monsters.png') no-repeat;
    background-size: calc(var(--aw) * var(--s) * 1px) auto;
    background-position: 0 calc(var(--y) * var(--s) * -1px);
    image-rendering: pixelated;
    animation: mon-idle calc(var(--n) * 166ms) steps(var(--n)) infinite;
}
@keyframes mon-idle { to { background-position-x: calc(var(--w) * var(--n) * var(--s) * -1px); } }
@media (prefers-reduced-motion: reduce) { .mon-sprite { animation: none; } }

.bestiary-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.bestiary-bar .tabs { margin: 0; flex: 1 1 auto; }
.bestiary-search { width: 220px; flex: 0 0 auto; }
.bestiary { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mon-card .stage { height: 128px; }
.mon-boss {
    position: absolute; top: 6px; left: 6px; z-index: 2;
    padding: 0 4px; font-size: 10px; color: var(--gold);
    background: var(--outline);
}
.mon-stage { height: 190px; }
.inspect .mon-stage { box-shadow: inset 0 0 0 4px var(--outline); }
.inspect-sub .mon-kind { margin-left: 10px; color: var(--gold); }
.mon-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mon-facts { grid-template-columns: minmax(0, 1fr); }
.mon-facts .v { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 10px; }
.elem { display: inline-flex; align-items: center; gap: 5px; color: var(--c); }
.elem::before { content: ''; width: 8px; height: 8px; background: var(--c); box-shadow: 0 0 0 2px var(--outline); }
.mon-where { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.mon-where li { padding: 0 6px; font-size: 14px; color: var(--text-2); }

@media (max-width: 720px) {
    .bestiary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .mon-card .stage { height: 124px; }
    .bestiary-search { width: 100%; }
    #bestiary-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
    #bestiary-tabs::-webkit-scrollbar { display: none; }
    #bestiary-tabs .tab { flex: 0 0 auto; }
    .inspect .mon-stage { height: 180px; }
}
/* Borrowing another monster's sheet until its own sprite is drawn. */
.mon-wip {
    position: absolute; top: 6px; right: 6px; z-index: 2;
    padding: 0 4px; font-size: 10px; color: var(--outline);
    background: var(--gold);
}
.inspect .mon-wip { top: 10px; right: 10px; font-size: 12px; }
