/* ============================================================================
   4Scenes Iberia - design system  (realm.css)
   ---------------------------------------------------------------------------
   One visual language for every page of the realm website: the home page, the
   download page, the account pages and the cash shop all load THIS file first
   and then one small page-layout sheet (realm-home.css, realm-pages.css,
   realm-shop.css). Nothing in those sheets invents a colour, a radius or a
   timing: they compose the tokens and components defined here.

   Palette: the "Iberia" night - deep navy surfaces, gold for everything that
   matters, and the two faction accents (Valorian blue, Derion red).

   Type: Cinzel for display (the carved-serif voice of the 4Scenes wordmark) and
   Inter for reading. Both come from Google Fonts with display=swap, so text
   renders immediately in the fallback stack and swaps in place; the fallback
   faces below are chosen for similar x-height and width to keep the shift
   small. The CSP already allows fonts.googleapis.com / fonts.gstatic.com.

   Artwork: public/img/keyart/* - our own key art rendered from the game's models (web-texture.jpg is the
   ambient texture behind every page, web-hero.jpg the home hero, web-valorian/web-derion.jpg the nation
   cards, web-forge.jpg the forge feature, web-banner.jpg the call-to-action band and page banners), the 4Scenes header
   and footer logo public/img/brand/4scenes-logo.png (favicons favicon-32.png /
   favicon.ico beside it), public/images/shop/page_*.png as decoration in the
   shop and the native item icons public/img/items/native/icon_<n>.png.
   Every image is decorative or captioned; the design renders complete without
   any of them.
   ========================================================================= */

/* ---------------------------------------------------------------- tokens */
:root {
    color-scheme: dark;

    /* surfaces, darkest to lightest */
    --navy-950: #040912;
    --navy-900: #07101f;
    --navy-800: #0b192c;
    --navy-700: #112640;
    --navy-600: #1a3454;
    --navy-500: #24466c;

    /* glass and lines */
    --glass: rgba(12, 26, 46, .68);
    --glass-2: rgba(8, 17, 32, .84);
    --glass-solid: rgba(7, 15, 28, .96);
    --line: rgba(160, 190, 225, .14);
    --line-2: rgba(160, 190, 225, .08);
    --line-hot: rgba(230, 192, 106, .55);
    --sheen: rgba(255, 255, 255, .06);
    --blur: saturate(140%) blur(14px);
    --blur-sm: saturate(130%) blur(8px);

    /* gold - the one accent that means "important" */
    --gold: #e6c06a;
    --gold-bright: #ffe6a6;
    --gold-deep: #b98a33;
    --gold-dark: #6e4f14;
    --gold-soft: rgba(230, 192, 106, .14);
    --gold-grad: linear-gradient(180deg, #fff0c4 0%, #e9c56f 48%, #c39437 100%);

    /* factions */
    --valorian: #4f9de6;
    --valorian-bright: #9dcdfa;
    --valorian-soft: rgba(79, 157, 230, .16);
    --derion: #e25b4a;
    --derion-bright: #ffa89c;
    --derion-soft: rgba(226, 91, 74, .16);

    /* semantic */
    --jade: #6fd39a;
    --rose: #f08a7a;
    --frost: #8fd4f2;
    --amber: #f3b756;

    /* text */
    --text: #e9eef6;
    --text-2: #b4c3d6;
    --text-3: #7f92a8;

    /* legacy aliases still referenced by older scripts and inline styles */
    --bg: var(--navy-900);
    --text-secondary: var(--text-2);
    --text-dim: var(--text-2);
    --blue: var(--frost);
    --success: var(--jade);
    --danger: var(--rose);
    --border: var(--line);
    --glass-line: var(--line);
    --glass-line-hot: var(--line-hot);
    --glass-sheen: var(--sheen);

    /* type */
    --font-display: "Cinzel", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --font-body: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --fs-xs: .75rem;
    --fs-sm: .875rem;
    --fs-base: 1rem;
    --fs-md: 1.125rem;
    --fs-lg: clamp(1.25rem, 1.1rem + .6vw, 1.5rem);
    --fs-xl: clamp(1.55rem, 1.25rem + 1.2vw, 2.1rem);
    --fs-2xl: clamp(1.95rem, 1.4rem + 2.4vw, 3rem);
    --fs-3xl: clamp(2.3rem, 1.5rem + 3.8vw, 4.1rem);
    --lh-tight: 1.12;
    --lh-body: 1.6;

    /* spacing - 4px rhythm */
    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 24px;
    --s6: 32px;
    --s7: 48px;
    --s8: 64px;
    --s9: 96px;

    /* shape */
    --r-sm: 6px;
    --r: 10px;
    --r-lg: 16px;
    --r-xl: 24px;
    --pill: 999px;
    /* aliases */
    --r1: var(--r-sm);
    --r2: var(--r);
    --r3: var(--r-lg);
    --r4: var(--r-xl);

    /* elevation */
    --sh1: 0 1px 2px rgba(0, 0, 0, .5);
    --sh2: 0 12px 28px -14px rgba(0, 0, 0, .75);
    --sh3: 0 28px 60px -24px rgba(0, 0, 0, .9);
    --gold-glow: 0 0 0 1px rgba(230, 192, 106, .35), 0 12px 32px -14px rgba(230, 192, 106, .55);

    /* motion */
    --t-fast: 130ms;
    --t: 220ms;
    --t-slow: 460ms;
    --ease: cubic-bezier(.22, .61, .36, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);

    --max-w: 1200px;
    --gutter: 24px;
    --header-h: 72px;
}

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

* { margin: 0; padding: 0; }

/* The HTML hidden attribute only sets display:none at user-agent weight, so a
   component rule with a display of its own would silently win. Restore it. */
[hidden] { display: none !important; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 16px);
    -webkit-text-size-adjust: 100%;
    background: var(--navy-950);
}

body {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font: 400 var(--fs-base)/var(--lh-body) var(--font-body);
    color: var(--text);
    background-color: var(--navy-950);
    background-image:
        radial-gradient(1100px 640px at 50% -12%, rgba(36, 92, 150, .32), transparent 62%),
        radial-gradient(760px 520px at 92% 0%, rgba(230, 192, 106, .07), transparent 58%),
        linear-gradient(180deg, #071224 0%, #040912 52%, #050b16 100%);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ambient stone texture: fixed, faint, fades out down the page */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background: url("/img/keyart/web-texture.jpg") center top / cover no-repeat;
    opacity: .5;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .55) 45%, rgba(0, 0, 0, .15) 100%);
    mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .55) 45%, rgba(0, 0, 0, .15) 100%);
    pointer-events: none;
}

/* fine grain so the large dark fields never band */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .045;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

main { flex: 1 0 auto; width: 100%; }

a {
    color: var(--gold);
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}

a:hover { color: var(--gold-bright); }

img, svg { display: block; max-width: 100%; }
img { height: auto; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:disabled { cursor: not-allowed; }
ul, ol { list-style: none; }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: var(--lh-tight);
    color: var(--gold-bright);
    letter-spacing: .01em;
    text-wrap: balance;
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }
strong { font-weight: 600; }
small { font-size: var(--fs-sm); }

::selection { background: rgba(230, 192, 106, .32); color: #fff; }

/* one visible focus ring for every interactive control */
:focus-visible {
    outline: 2px solid var(--gold-bright);
    outline-offset: 3px;
    border-radius: var(--r-sm);
}

* { scrollbar-width: thin; scrollbar-color: rgba(120, 165, 205, .45) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: rgba(0, 0, 0, .25); }
*::-webkit-scrollbar-thumb {
    background: rgba(120, 165, 205, .38);
    border-radius: var(--pill);
    border: 2px solid transparent;
    background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(160, 200, 235, .6); background-clip: content-box; }

/* --------------------------------------------------------------- layout */
.container {
    width: min(var(--max-w), calc(100% - var(--gutter) * 2));
    margin-inline: auto;
}

.site-content { padding-block: var(--s6) var(--s7); }
.site-content.is-narrow { max-width: 780px; }

.stack { display: grid; gap: var(--s4); }
.stack-lg { display: grid; gap: var(--s6); }

/* -------------------------------------------------------------- utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    left: 16px;
    top: -90px;
    z-index: 200;
    padding: 12px 18px;
    border-radius: var(--r);
    border: 1px solid var(--line-hot);
    background: var(--glass-solid);
    color: var(--gold-bright);
    transition: top var(--t) var(--ease);
}
.skip-link:focus { top: 14px; }

.eyebrow {
    display: block;
    margin: 0 0 var(--s2);
    font: 600 var(--fs-xs)/1.4 var(--font-body);
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--gold);
}

.lead { font-size: var(--fs-md); color: var(--text-2); max-width: 60ch; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.tiny { font-size: var(--fs-sm); }
.tabular { font-variant-numeric: tabular-nums; }
.text-center { text-align: center; }

/* gold gradient text for the one word that should shine */
.gilt {
    background: var(--gold-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--gold-bright);
}
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
    .gilt { -webkit-text-fill-color: currentColor; background: none; }
}

/* ornamental rule: hairlines meeting a gold diamond */
.ornament {
    display: flex;
    align-items: center;
    gap: var(--s3);
    margin: var(--s4) 0;
    color: var(--gold);
}
.ornament::before,
.ornament::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--line-hot));
}
.ornament::after { background: linear-gradient(90deg, var(--line-hot), transparent); }
.ornament .gem,
.gem {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--gold-grad);
    transform: rotate(45deg);
    border-radius: 1px;
    box-shadow: 0 0 10px rgba(230, 192, 106, .5);
}

.rule {
    height: 1px;
    border: 0;
    margin: var(--s5) 0;
    background: linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 82%, transparent);
}

/* section heading with the ornament */
.section-head {
    display: grid;
    gap: var(--s2);
    margin-bottom: var(--s5);
    text-align: center;
    justify-items: center;
}
.section-head h2 { font-size: var(--fs-xl); }
.section-head p { max-width: 62ch; color: var(--text-2); }
.section-head .ornament { width: min(320px, 100%); margin: var(--s1) 0 0; }
.section-head.is-left { text-align: left; justify-items: start; }
.section-head.is-left .ornament { width: 200px; }

/* page title block for the inner pages */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s4) var(--s6);
    margin-bottom: var(--s5);
}
.page-head h1 { font-size: var(--fs-2xl); }
.page-head p { margin: var(--s2) 0 0; max-width: 58ch; color: var(--text-2); }

/* ------------------------------------------------------------- app bar */
.site-header {
    position: sticky;
    top: 0;
    z-index: 60;
    border-bottom: 1px solid rgba(230, 192, 106, .16);
    background: linear-gradient(180deg, rgba(5, 11, 22, .86), rgba(5, 11, 22, .62));
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    transition: background var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}
.site-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--line-hot) 30%, var(--line-hot) 70%, transparent);
    opacity: .6;
    pointer-events: none;
}
.site-header.is-scrolled {
    background: linear-gradient(180deg, rgba(4, 9, 18, .96), rgba(4, 9, 18, .9));
    box-shadow: 0 14px 34px -22px rgba(0, 0, 0, .95);
}

.nav-container {
    width: min(var(--max-w), calc(100% - var(--gutter) * 2));
    min-height: var(--header-h);
    margin-inline: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--s4);
}

/* the 4Scenes wordmark (W14): one transparent PNG, scaled to --logo-h and
   contained in a box --logo-ratio times as wide (the wordmark is 600x117;
   any other ratio still fits, left-aligned). Hover lights it with a gold glow
   instead of the old sprite's second state. */
.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 6px 2px;
    color: var(--gold);
}
.logo:hover { color: var(--gold-bright); }
.logo-img {
    --logo-h: 36px;               /* 185 px wide (the old sprite was 128 x 44 px) */
    --logo-ratio: 5.13;
    flex: none;
    width: calc(var(--logo-h) * var(--logo-ratio));
    height: var(--logo-h);
    background: url("/img/brand/4scenes-logo.png") left center / contain no-repeat;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .6));
    transition: transform var(--t) var(--ease), filter var(--t) var(--ease);
}
.logo:hover .logo-img {
    transform: translateY(-1px);
    filter: brightness(1.12) drop-shadow(0 2px 10px rgba(230, 192, 106, .45));
}
.logo-realm {
    display: grid;
    line-height: 1;
    padding-left: 12px;
    border-left: 1px solid var(--line-hot);
}
.logo-realm b {
    font: 600 1rem/1 var(--font-display);
    letter-spacing: .08em;
    color: var(--gold-bright);
}
.logo-realm small {
    margin-top: 4px;
    font: 600 .58rem/1 var(--font-body);
    letter-spacing: .3em;
    text-transform: uppercase;
    color: var(--text-3);
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
}
.nav-links a {
    position: relative;
    padding: 10px 13px;
    border-radius: var(--pill);
    white-space: nowrap;
    font: 600 .78rem/1 var(--font-body);
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-2);
    transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.nav-links a::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 3px;
    height: 1.5px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    transform: scaleX(0);
    transition: transform var(--t) var(--ease);
}
.nav-links a:hover { color: var(--gold-bright); background: rgba(255, 255, 255, .05); }
.nav-links a:hover::after { transform: scaleX(1); }
.nav-links a.active { color: var(--gold-bright); background: var(--gold-soft); }
.nav-links a.active::after { transform: scaleX(1); }

.nav-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--s2);
}

/* signed-in identity chip built by auth-nav.js */
.nav-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 6px;
    border-radius: var(--pill);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .05);
    font-size: var(--fs-sm);
    color: var(--text);
    max-width: 200px;
}
.nav-user b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: var(--gold-bright);
}
.nav-user .avatar {
    flex: none;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--navy-500), var(--navy-800));
    box-shadow: inset 0 0 0 1px rgba(230, 192, 106, .5);
    font: 600 .68rem/1 var(--font-display);
    color: var(--gold-bright);
}

/* hamburger, only rendered below the tablet breakpoint */
.nav-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .04);
    place-items: center;
}
.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--gold);
    transition: transform var(--t) var(--ease), opacity var(--t) var(--ease);
}
.nav-toggle span { position: relative; }
.nav-toggle span::before,
.nav-toggle span::after { content: ""; position: absolute; left: 0; }
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }
.site-header.is-open .nav-toggle span { background: transparent; }
.site-header.is-open .nav-toggle span::before { transform: translateY(6px) rotate(45deg); }
.site-header.is-open .nav-toggle span::after { transform: translateY(-6px) rotate(-45deg); }

/* ------------------------------------------------------------- buttons */
.btn,
.nav-btn,
.shop-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    min-height: 44px;
    padding: 10px 22px;
    border-radius: var(--pill);
    border: 1px solid rgba(255, 255, 255, .14);
    background: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .03));
    box-shadow: var(--sh1), inset 0 1px 0 var(--sheen);
    font: 600 var(--fs-sm)/1.15 var(--font-body);
    letter-spacing: .03em;
    color: var(--text);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease),
                border-color var(--t) var(--ease), background var(--t) var(--ease), color var(--t-fast) var(--ease);
}
.nav-btn { min-height: 38px; padding: 8px 15px; font-size: var(--fs-xs); letter-spacing: .06em; }

/* light sweep on hover */
.btn::after,
.nav-btn::after,
.shop-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 32%, rgba(255, 255, 255, .32) 48%, transparent 64%);
    transform: translateX(-120%);
    transition: transform var(--t-slow) var(--ease-out);
    pointer-events: none;
}
.btn:hover::after, .nav-btn:hover::after, .shop-btn:hover::after { transform: translateX(120%); }

.btn:hover, .nav-btn:hover, .shop-btn:hover {
    transform: translateY(-1px);
    border-color: var(--line-hot);
    color: var(--gold-bright);
    box-shadow: var(--sh2), inset 0 1px 0 var(--sheen);
}
.btn:active, .nav-btn:active, .shop-btn:active { transform: translateY(0) scale(.985); }

.btn-gold, .nav-btn-gold {
    border-color: #f7e3ad;
    background: var(--gold-grad);
    color: #2b1d05;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
    box-shadow: var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, .6), inset 0 -2px 0 rgba(110, 79, 20, .35);
}
.btn-gold:hover, .nav-btn-gold:hover {
    color: #1d1403;
    border-color: #fff3d0;
    box-shadow: 0 0 0 1px rgba(255, 230, 166, .55), 0 16px 34px -12px rgba(230, 192, 106, .7), inset 0 1px 0 rgba(255, 255, 255, .65);
}

.btn-outline, .nav-btn-outline {
    background: rgba(230, 192, 106, .06);
    border-color: rgba(230, 192, 106, .45);
    color: var(--gold-bright);
}
.btn-ghost {
    background: rgba(255, 255, 255, .04);
    border-color: var(--line);
    color: var(--text);
}
.btn-quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-quiet:hover { background: rgba(255, 255, 255, .06); box-shadow: none; }

.btn-valorian { border-color: rgba(79, 157, 230, .5); background: var(--valorian-soft); color: var(--valorian-bright); }
.btn-derion { border-color: rgba(226, 91, 74, .5); background: var(--derion-soft); color: var(--derion-bright); }

.btn-sm { min-height: 36px; padding: 7px 14px; font-size: var(--fs-xs); }
.btn-lg { min-height: 52px; padding: 14px 30px; font-size: var(--fs-base); letter-spacing: .04em; }
.btn-block { width: 100%; }
.btn-icon { width: 18px; height: 18px; flex: none; }

.btn:disabled, .shop-btn:disabled, .btn[aria-disabled="true"] {
    opacity: .5;
    transform: none !important;
    box-shadow: none;
    filter: grayscale(.4);
}
.btn:disabled::after, .shop-btn:disabled::after { display: none; }

/* --------------------------------------------------------------- panels */
.panel,
.form-card,
.glass {
    position: relative;
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--glass), var(--glass-2));
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    box-shadow: var(--sh2), inset 0 1px 0 var(--sheen);
}

/* the diagonal light catch that makes the glass read as glass */
.panel::before,
.form-card::before,
.glass::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(142deg, rgba(255, 255, 255, .09) 0%, rgba(255, 255, 255, .02) 34%, transparent 58%);
}
.panel > *, .form-card > *, .glass > * { position: relative; }

.panel-pad, .glass { padding: var(--s5); }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s4);
    padding: var(--s4) var(--s5);
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, .04), transparent);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.panel-heading,
.panel-head h2,
.panel-head h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font: 600 .8rem/1.3 var(--font-body);
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--gold);
}
.panel-heading::before,
.panel-head h2::before,
.panel-head h3::before {
    content: "";
    width: 6px;
    height: 6px;
    background: var(--gold-grad);
    transform: rotate(45deg);
    border-radius: 1px;
    flex: none;
}
.panel-heading {
    padding: var(--s4) var(--s5);
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, .04), transparent);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}

/* gold-framed variant for the surfaces that carry the primary action */
.panel-gold { border-color: rgba(230, 192, 106, .35); box-shadow: var(--gold-glow), var(--sh2); }

/* interactive card */
.card-link {
    display: block;
    color: inherit;
    transition: transform var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.card-link:hover {
    transform: translateY(-3px);
    border-color: var(--line-hot);
    box-shadow: var(--sh3), var(--gold-glow), inset 0 1px 0 var(--sheen);
    color: inherit;
}

/* icon tile: a native 32px game icon in a bevelled slot */
.icon-slot {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    flex: none;
    border-radius: var(--r);
    border: 1px solid rgba(230, 192, 106, .3);
    background:
        radial-gradient(70% 70% at 50% 28%, rgba(255, 255, 255, .1), transparent 70%),
        linear-gradient(160deg, var(--navy-700), var(--navy-900));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 4px 10px rgba(0, 0, 0, .5);
}
.icon-slot img {
    width: 36px;
    height: 36px;
    image-rendering: pixelated;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .7));
}
.icon-slot.is-lg { width: 72px; height: 72px; }
.icon-slot.is-lg img { width: 48px; height: 48px; }

/* -------------------------------------------------------------- badges */
.badge,
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: var(--pill);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .05);
    font: 600 var(--fs-xs)/1.4 var(--font-body);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-2);
    white-space: nowrap;
}
.badge-gold, .chip-gold { border-color: rgba(230, 192, 106, .45); background: var(--gold-soft); color: var(--gold-bright); }
.badge-jade, .chip-jade { border-color: rgba(111, 211, 154, .4); background: rgba(111, 211, 154, .12); color: var(--jade); }
.badge-rose, .chip-rose { border-color: rgba(240, 138, 122, .4); background: rgba(240, 138, 122, .12); color: var(--rose); }
.badge-frost { border-color: rgba(143, 212, 242, .4); background: rgba(143, 212, 242, .12); color: var(--frost); }
.badge-amber { border-color: rgba(243, 183, 86, .4); background: rgba(243, 183, 86, .12); color: var(--amber); }
.badge-valorian { border-color: rgba(79, 157, 230, .5); background: var(--valorian-soft); color: var(--valorian-bright); }
.badge-derion { border-color: rgba(226, 91, 74, .5); background: var(--derion-soft); color: var(--derion-bright); }

/* the discount tag used by the shop and the promotion cards */
.tag-off {
    display: inline-block;
    padding: 3px 9px;
    border-radius: var(--pill);
    background: linear-gradient(180deg, #ffa89c, #c9503f);
    color: #2a0f08;
    font: 700 var(--fs-xs)/1.5 var(--font-body);
    box-shadow: var(--sh1);
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .08);
}
.dot-live { animation: pulse 2.6s var(--ease) infinite; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(111, 211, 154, .14); }
    50% { box-shadow: 0 0 0 6px rgba(111, 211, 154, .03); }
}

.online { color: var(--jade); }
.offline { color: var(--rose); }

/* the moonstone glyph, identical on every page */
.ms {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    font-variant-numeric: tabular-nums;
    color: var(--gold-bright);
}
.ms::before {
    content: "";
    width: 9px;
    height: 9px;
    align-self: center;
    background: linear-gradient(140deg, #fff3cf, #e6c06a 45%, #b98a33);
    box-shadow: 0 0 8px rgba(230, 192, 106, .55);
    transform: rotate(45deg);
    border-radius: 2px;
}

/* --------------------------------------------------------------- forms */
.form-card {
    width: min(480px, 100%);
    margin: var(--s5) auto;
    padding: var(--s6);
    border-radius: var(--r-xl);
    overflow: hidden;
}
.form-card::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold) 30%, var(--gold) 70%, transparent);
    pointer-events: none;
}
.form-card h1, .form-card h2 { margin-bottom: var(--s2); text-align: center; font-size: var(--fs-xl); }
.form-card .eyebrow { text-align: center; }

.auth-note {
    margin-bottom: var(--s5);
    text-align: center;
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.form-group { margin-bottom: var(--s4); }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font: 600 var(--fs-xs)/1.4 var(--font-body);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-2);
}
.form-hint {
    display: block;
    margin-top: 6px;
    font-size: var(--fs-xs);
    color: var(--text-3);
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
    border-radius: var(--r);
    border: 1px solid rgba(160, 190, 225, .22);
    background: rgba(3, 9, 18, .62);
    color: var(--text);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, .4);
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
input::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: rgba(160, 190, 225, .38); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--line-hot);
    background: rgba(5, 13, 25, .8);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, .4), 0 0 0 3px rgba(230, 192, 106, .18);
}
input[type="search"]::-webkit-search-cancel-button { filter: invert(.7); }
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23e6c06a' stroke-width='1.6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

/* validation: the browser's own verdict once the field has been touched, and
   an explicit class a script can set */
input:user-invalid,
.form-group.is-invalid input {
    border-color: rgba(240, 138, 122, .7);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, .4), 0 0 0 3px rgba(240, 138, 122, .16);
}
input:user-valid:not(:placeholder-shown),
.form-group.is-valid input {
    border-color: rgba(111, 211, 154, .55);
}
.form-group.is-invalid .form-hint { color: var(--rose); }

.form-footer {
    margin-top: var(--s5);
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-2);
}

/* status messages - class names are produced by the page scripts, keep them */
.form-error,
.form-success,
.form-info,
.shop-message {
    display: flex;
    align-items: flex-start;
    gap: var(--s3);
    padding: 12px 15px;
    margin: var(--s4) 0;
    border-radius: var(--r);
    border: 1px solid rgba(240, 138, 122, .4);
    background: rgba(74, 32, 28, .5);
    color: #ffd7c6;
    font-size: var(--fs-sm);
    line-height: 1.5;
    animation: rise var(--t) var(--ease-out);
}
.form-error::before,
.form-success::before,
.form-info::before {
    content: "!";
    flex: none;
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(240, 138, 122, .25);
    font: 700 .72rem/1 var(--font-body);
    color: var(--rose);
}
.form-success { border-color: rgba(111, 211, 154, .4); background: rgba(24, 56, 39, .5); color: #cdf0d2; }
.form-success::before { content: "\2713"; background: rgba(111, 211, 154, .25); color: var(--jade); }
.form-info { border-color: rgba(143, 212, 242, .35); background: rgba(20, 44, 64, .55); color: #d6ecf7; }
.form-info::before { content: "i"; background: rgba(143, 212, 242, .22); color: var(--frost); }
.shop-message {
    align-items: center;
    justify-content: space-between;
    border-color: var(--line);
    background: rgba(12, 26, 46, .75);
    -webkit-backdrop-filter: var(--blur-sm);
    backdrop-filter: var(--blur-sm);
    color: var(--text);
}

/* -------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
th {
    padding: 10px var(--s3);
    text-align: left;
    font: 600 var(--fs-xs)/1.4 var(--font-body);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--gold);
    border-bottom: 1px solid var(--line-hot);
    white-space: nowrap;
}
td {
    padding: 12px var(--s3);
    border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
}
tbody tr { transition: background var(--t-fast) var(--ease); }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, .02); }
tbody tr:hover { background: rgba(230, 192, 106, .06); }
tbody tr:last-child td { border-bottom: 0; }

/* class + nation colours referenced by the account and home scripts */
.class-warrior { color: #f4b6a4; }
.class-assassin { color: #c9bcf2; }
.class-archer { color: #b0d8a2; }
.class-mage { color: #9fd0f1; }
.class-priest { color: #f7e6ae; }
.class-summoner { color: #dcb8ec; }
.country-defugel { color: var(--valorian-bright); }
.country-craxion { color: var(--derion-bright); }

/* -------------------------------------------------------------- toasts */
.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 120;
    display: grid;
    gap: var(--s3);
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    position: relative;
    pointer-events: auto;
    padding: var(--s4) var(--s6) var(--s4) var(--s4);
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(18, 36, 60, .96), rgba(7, 15, 28, .97));
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    box-shadow: var(--sh3), inset 0 1px 0 var(--sheen);
    color: var(--text);
    overflow: hidden;
    animation: toast-in var(--t-slow) var(--ease-out);
}
.toast::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gold);
}
.toast-success::before { background: linear-gradient(180deg, var(--jade), #3f9a62); }
.toast-error::before { background: linear-gradient(180deg, var(--rose), #b4573f); }
.toast-success { border-color: rgba(111, 211, 154, .32); }
.toast-error { border-color: rgba(240, 138, 122, .32); }
.toast-title { margin-bottom: 4px; font: 600 var(--fs-base)/1.3 var(--font-display); color: var(--gold-bright); }
.toast-success .toast-title { color: #d3f2d8; }
.toast-error .toast-title { color: #ffd6c8; }
.toast-msg { font-size: var(--fs-sm); color: var(--text-2); }
.toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 1.15rem;
    line-height: 1;
    color: var(--text-2);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.toast-close:hover { background: rgba(255, 255, 255, .09); color: var(--text); }
.toast.is-leaving { animation: toast-out var(--t) var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(26px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(26px) scale(.97); } }

/* ------------------------------------------------------------ CTA band */
/* "Ready to enter Iberia?" - launcher-header.png as the art, shared by the
   home and download pages. */
.cta-band {
    position: relative;
    margin-top: var(--s8);
    border-block: 1px solid rgba(230, 192, 106, .22);
    background: var(--navy-900);
    overflow: hidden;
}
/* the fire creature from launcher-header.png, its own wordmark cropped away
   (the art's left 230px), faded into the band on the left */
.cta-band::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: -4px;
    /* the banner art is 1600x320 (5:1), its clash centred */
    aspect-ratio: 5 / 1;
    max-width: 100%;
    background: url("/img/keyart/web-banner.jpg") right center / auto 100% no-repeat;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 45%);
    mask-image: linear-gradient(90deg, transparent, #000 45%);
    opacity: .85;
    pointer-events: none;
}
.cta-band::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(60% 120% at 80% 50%, rgba(255, 120, 40, .16), transparent 70%),
        linear-gradient(180deg, rgba(4, 9, 18, .35), rgba(4, 9, 18, .55));
    pointer-events: none;
}
.cta-band .container {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s4) var(--s6);
    min-height: 168px;
    padding-block: var(--s6);
}
.cta-band h2 { font-size: var(--fs-xl); }
.cta-band p { margin: 6px 0 0; color: var(--text-2); max-width: 52ch; }
.cta-actions { display: flex; flex-wrap: wrap; gap: var(--s3); }

/* -------------------------------------------------------------- footer */
.site-footer {
    flex: none;
    margin-top: var(--s8);
    border-top: 1px solid rgba(230, 192, 106, .16);
    background:
        linear-gradient(180deg, rgba(4, 9, 18, .3), rgba(3, 7, 14, .92)),
        url("/img/keyart/web-texture.jpg") center / cover no-repeat,
        var(--navy-950);
    color: var(--text-3);
    font-size: var(--fs-sm);
}
.cta-band + .site-footer { margin-top: 0; border-top: 0; }

.footer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr));
    gap: var(--s6);
    padding-block: var(--s7) var(--s5);
}
.footer-brand { display: grid; gap: var(--s3); justify-items: start; }
.footer-brand .logo-img { --logo-h: 40px; }
.footer-brand p { max-width: 40ch; }
.footer-col h3 {
    margin-bottom: var(--s3);
    font: 600 var(--fs-xs)/1.4 var(--font-body);
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--gold);
}
.footer-col ul { display: grid; gap: 6px; }
.footer-col a { color: var(--text-2); }
.footer-col a:hover { color: var(--gold-bright); }

.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s2) var(--s4);
    padding-block: var(--s4) var(--s5);
    border-top: 1px solid var(--line-2);
    font-size: var(--fs-xs);
    line-height: 1.7;
}
.footer-bottom a { color: var(--text-2); }
.footer-bottom a:hover { color: var(--gold); }

/* -------------------------------------------------------------- motion */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Reveal-on-scroll. Only armed once realm.js has flagged <html class="js">,
   so a script failure can never leave the page invisible. */
.js .reveal { opacity: 0; }
.js .reveal.in { animation: rise var(--t-slow) var(--ease-out) forwards; animation-delay: var(--reveal-delay, 0ms); }
.page-enter { animation: fade var(--t-slow) var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }
    .js .reveal { opacity: 1 !important; }
    .btn:hover, .nav-btn:hover, .shop-btn:hover, .card-link:hover { transform: none; }
}

/* ---------------------------------------------------------- responsive */
/* W14: the 4Scenes wordmark is wider than the old sprite; below 1280px the
   "Iberia" tag beside it gives the room back to the links. */
@media (max-width: 1279px) {
    .site-header .logo-realm { display: none; }
}
@media (max-width: 960px) {
    :root { --header-h: 64px; }

    .nav-container {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas: "logo actions toggle" "links links links";
        padding-block: 8px;
        gap: 0 var(--s3);
    }
    .logo { grid-area: logo; }
    .nav-right { grid-area: actions; }
    .nav-toggle { grid-area: toggle; display: grid; }
    .nav-links {
        grid-area: links;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: var(--s3) 0 var(--s2);
        border-top: 1px solid var(--line-2);
        margin-top: 8px;
    }
    .nav-links a { padding: 12px 14px; border-radius: var(--r); font-size: var(--fs-sm); letter-spacing: .06em; }
    .nav-links a::after { display: none; }
    .nav-links a.active { border-left: 2px solid var(--gold); }
    /* no script: show the links as a wrapped row instead of hiding them */
    html:not(.js) .nav-links { display: flex; flex-direction: row; flex-wrap: wrap; }
    html:not(.js) .nav-toggle { display: none; }
    .site-header.is-open .nav-links { display: flex; animation: rise var(--t) var(--ease-out); }

    .footer-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
    :root { --gutter: 16px; }

    .site-content { padding-block: var(--s5) var(--s6); }
    .logo-img { --logo-h: 22px; }     /* 113 px wide, the old sprite took 104 px here */
    .logo-realm { display: none; }
    .nav-btn { min-height: 34px; padding: 7px 11px; }
    .nav-user { max-width: 34px; padding: 4px; }
    .nav-user b { display: none; }
    .form-card { padding: var(--s5) var(--s4); margin-block: var(--s3); }
    .glass, .panel-pad { padding: var(--s4); }
    .toast-container { right: 12px; bottom: 12px; }
    th, td { padding: 10px 8px; }
    .page-head h1 { font-size: var(--fs-xl); }
    .cta-band .container { min-height: 0; }
    .cta-band::before { aspect-ratio: auto; width: 100%; background-size: auto 70%; background-position: right -120px bottom; opacity: .5; }
    .cta-actions .btn { flex: 1 1 auto; }
    .footer-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s5); padding-top: var(--s6); }
    .footer-bottom { justify-content: center; text-align: center; }
}

/* ---------------------------------------------------------------- tabs */
/* W18: one board at a time (home rankings rail, /rankings). Buttons with role="tab"; realm-boards.js moves .is-active. */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: var(--s3) var(--s4) 0;
}
.tab {
    padding: 7px 12px;
    border-radius: var(--pill);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .04);
    font: 600 var(--fs-xs)/1.2 var(--font-body);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-2);
    cursor: pointer;
    transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.tab:hover { color: var(--gold-bright); border-color: var(--line-hot); }
.tab.is-active { color: var(--gold-bright); background: var(--gold-soft); border-color: rgba(230, 192, 106, .55); }
.tabs-lg { padding: var(--s4) var(--s5) 0; gap: 8px; }
.tabs-lg .tab { padding: 9px 16px; font-size: var(--fs-sm); letter-spacing: .06em; text-transform: none; }

/* W18: seven links in the header (Rankings, Events and the optional Discord joined the four) - between the hamburger
   breakpoint and 1180px the row is tightened so it never runs into the account buttons. */
@media (max-width: 1180px) and (min-width: 961px) {
    .nav-links { gap: 0; }
    .nav-links a { padding: 10px 8px; letter-spacing: .05em; font-size: .72rem; }
    .nav-links a::after { left: 8px; right: 8px; }
    .nav-btn { padding: 8px 11px; }
}

/* a small link in a panel head ("All rankings", "Full calendar") */
.panel-more { font: 600 var(--fs-xs)/1 var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--gold); white-space: nowrap; }
.panel-more::after { content: " \2192"; }
.panel-more:hover { color: var(--gold-bright); }
