/* =====================================================================================
   CORNER WARS — Design System v1.0 (1:1 from Terrace Wars, terracewars.com)
   Built from the designers' screen mockups (D:\TERRACEWARS\Дизайн страниц) and the
   "UI Design System v0.1" brief. Dark, gritty, cinematic; readable first.
   One brand accent (terrace red) for actions and the active state; club colours are a
   *faction* accent (crests, fan power, your side) and never replace the brand red.
   Docs: docs/DESIGN_SYSTEM.md · Living styleguide: /design-system.html
   ===================================================================================== */

/* ---- 1. Tokens ---------------------------------------------------------------------- */
:root {
  /* surfaces (darkest → lightest) */
  --bg: #07090c;            /* page */
  --surface: #12161b;       /* panels */
  --surface-2: #171c22;     /* rows, tiles, raised */
  --surface-3: #1f252c;     /* hover */
  --inset: #0b0e12;         /* inputs, item slots, wells */
  --line: #262c34;          /* dividers inside panels */
  --border: #39414b;        /* panel outline */
  --border-strong: #4d5661; /* inputs, secondary buttons */

  /* text */
  --text: #e9edf2;
  --text-2: #c2c9d1;
  --muted: #9aa3ad;         /* 6.6:1 on --surface */
  --faint: #6b737d;         /* decorative only, never for meaning */

  /* brand */
  --red: #d72c35;
  --red-hover: #f04a53;
  --red-deep: #7d151c;
  --red-ink: #ff6b72;       /* red text on dark: 5.1:1 */
  --red-soft: rgba(215, 44, 53, .14);
  --red-glow: rgba(240, 74, 83, .42);

  /* semantic */
  --gold: #e2b55e;          /* coins, ranks, legendary */
  --silver: #b4bcc6;
  --bronze: #c0804f;
  --green: #58b888;         /* success, win, claimed */
  --green-soft: rgba(88, 184, 136, .14);
  --danger: #f05b61;        /* loss, error */
  --warning: #e8a23a;
  --info: #4c8fe0;

  /* the five attributes — consistent everywhere (bars, icons, chips) */
  --stat-str: #e5484d;
  --stat-agi: #4cc38a;
  --stat-con: #3f8fe0;
  --stat-ins: #9b6ef3;
  --stat-prs: #e8a23a;
  --stat-int: #3fc6d6;

  /* rarity */
  --r-common: #8b939c;
  --r-uncommon: #4cc38a;
  --r-rare: #3f8fe0;
  --r-epic: #a066f0;
  --r-legendary: #e8a23a;

  /* faction accent — set per player (own club) and per fixture (rival) */
  --club: #d72c35;
  --club-2: #ffffff;
  --rival: #3f8fe0;

  /* type */
  --font-display: 'Twemoji Country Flags', 'Oswald', 'Roboto Condensed', 'Arial Narrow', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-body: 'Twemoji Country Flags', 'Roboto Condensed', 'Arial Narrow', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 15px; --fs-md: 17px; --fs-lg: 20px; --fs-xl: 26px; --fs-2xl: 34px;
  --fs-hero: clamp(38px, 5.2vw, 76px);

  /* shape, depth, motion */
  --r-sm: 4px; --r-md: 6px; --r-lg: 10px; --r-pill: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --shadow: 0 12px 28px rgba(0, 0, 0, .45);
  --glow: 0 0 0 1px var(--red), 0 0 18px var(--red-glow);
  --fast: 120ms ease; --med: 200ms ease;
  --topbar-h: 68px;
  color-scheme: dark;
}
/* Japanese: Japanese faces before the Chinese ones, so kanji get Japanese glyph shapes */
:root:lang(ja) {
  --font-display: 'Twemoji Country Flags', 'Oswald', 'Roboto Condensed', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', 'Noto Sans JP', sans-serif;
  --font-body: 'Twemoji Country Flags', 'Roboto Condensed', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', 'Noto Sans JP', sans-serif;
}

/* flag emoji: Windows has none — a flags-only font (Twemoji, self-hosted) covers just the regional-indicator range */
@font-face { font-family: 'Twemoji Country Flags'; src: url('/fonts/TwemojiCountryFlags.woff2') format('woff2'); unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E007F; font-display: swap; }

/* ---- 2. Base ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font: 400 var(--fs-base)/1.45 var(--font-body);
  color: var(--text);
  /* red stadium glow + vignette; works without any background image */
  background:
    radial-gradient(1200px 520px at 62% -12%, rgba(150, 22, 30, .38), transparent 62%),
    radial-gradient(900px 600px at -10% 110%, rgba(110, 16, 24, .22), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
/* grunge grain overlay (pure CSS, no image) */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: repeating-radial-gradient(circle at 17% 32%, rgba(255,255,255,.012) 0 1px, transparent 1px 3px),
                    repeating-radial-gradient(circle at 83% 71%, rgba(0,0,0,.25) 0 1px, transparent 1px 4px);
}
body > * { position: relative; z-index: 1; }
a { color: inherit; text-decoration: none; }
a.link { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; font-size: var(--fs-sm); }
a.link:hover { color: var(--text); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, .display {
  font-family: var(--font-display); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; line-height: 1.1; margin: 0;
}
h1 { font-size: var(--fs-2xl); } h2 { font-size: var(--fs-xl); } h3 { font-size: var(--fs-lg); } h4 { font-size: var(--fs-md); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: var(--fs-sm); } .xs { font-size: var(--fs-xs); }
.red { color: var(--red-ink); } .gold { color: var(--gold); } .green { color: var(--green); } .danger { color: var(--danger); }
.upper { text-transform: uppercase; letter-spacing: .04em; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
::selection { background: var(--red); color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; gap: var(--s2); } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.right { text-align: right; } .center { text-align: center; }

/* ---- 3. Shell: top bar, navigation, resources -------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: stretch; gap: var(--s3); padding: 0 var(--s4);
  background: linear-gradient(180deg, rgba(10, 12, 16, .98), rgba(8, 10, 13, .96));
  border-bottom: 1px solid #5c1d22; box-shadow: 0 8px 24px rgba(0, 0, 0, .55);
}
.topbar .brand { display: flex; align-items: center; padding-right: var(--s3); }
.topbar .brand img { height: 46px; width: auto; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); }
.nav { display: flex; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: flex; align-items: center; gap: var(--s2); padding: 0 18px; white-space: nowrap;
  font: 500 15px/1 var(--font-display); text-transform: uppercase; letter-spacing: .04em; color: #dfe4ea;
  border-left: 1px solid #222830; transition: background var(--fast), color var(--fast);
}
.nav a:hover { background: rgba(255, 255, 255, .04); color: #fff; }
.nav a.active, .nav a[aria-current="page"] {
  color: #fff; background: linear-gradient(180deg, #4a1016, #9a1a22 85%, #3a0b0f);
  box-shadow: inset 0 0 0 1px #c9363e, 0 0 18px rgba(215, 44, 53, .35);
}
.nav a .badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); }
.resources { display: flex; align-items: center; gap: var(--s2); }
.res {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px 0 10px;
  background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-sm);
  font: 600 16px/1 var(--font-body); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.res .add { width: 26px; height: 26px; display: grid; place-items: center; color: var(--text-2); border-left: 1px solid var(--line); margin-left: 4px; }
.res .add:hover { color: #fff; }
.icon-btn {
  position: relative; width: 40px; height: 40px; display: grid; place-items: center; color: var(--text-2);
  background: transparent; border: 0; border-radius: var(--r-sm); cursor: pointer;
}
.icon-btn:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; min-width: 9px; height: 9px; border-radius: 9px; background: var(--red); box-shadow: 0 0 6px var(--red); }

/* page layouts (desktop three-column like the mockups; stacks below 1024 px) */
.page { padding: var(--s4); max-width: 1920px; margin: 0 auto; }
.layout-3 { display: grid; grid-template-columns: 320px minmax(0, 1fr) 360px; gap: var(--s4); align-items: start; }
.layout-2 { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: var(--s4); align-items: start; }
.col { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
@media (max-width: 1439px) { .layout-3 { grid-template-columns: 280px minmax(0, 1fr) 320px; } }
@media (max-width: 1199px) { .layout-3 { grid-template-columns: 260px minmax(0, 1fr); } .layout-3 > .col:last-child { grid-column: 1 / -1; } }
@media (max-width: 1023px) {
  .layout-3, .layout-2 { grid-template-columns: 1fr; }
  .topbar .nav { display: none; }                 /* mobile: bottom navigation instead */
  .bottom-nav { display: flex; }
}
@media (max-width: 767px) {
  .grid-2 { grid-template-columns: 1fr; }
  /* attribute row: name · value · + on one line, the bar underneath */
  .stat-line { grid-template-columns: 22px 1fr auto 32px; row-gap: 8px; }
  .stat-line .seg { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) {
  :root { --fs-base: 15px; --topbar-h: 56px; }
  .res { height: 34px; padding: 0 8px; font-size: 14px; }
  .page { padding: var(--s3); }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar .brand img { height: 34px; }
  .res .add { display: none; }
}
.bottom-nav {
  display: none; position: fixed; inset: auto 0 0 0; z-index: 30; height: 60px; padding-bottom: env(safe-area-inset-bottom);
  background: rgba(8, 10, 13, .97); border-top: 1px solid #5c1d22; overflow-x: auto;
}
.bottom-nav a { flex: 1 0 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font: 500 11px/1 var(--font-display); text-transform: uppercase; color: var(--muted); }
.bottom-nav a.active { color: #fff; box-shadow: inset 0 2px 0 var(--red); background: linear-gradient(180deg, rgba(215,44,53,.22), transparent); }
@media (max-width: 1023px) { .bottom-nav { display: flex; } }   /* after the base rule, so it wins */

/* ---- 4. Panels & headings ------------------------------------------------------------------ */
.panel {
  background: linear-gradient(135deg, rgba(20, 25, 31, .96), rgba(13, 16, 21, .96));
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: var(--s4); min-width: 0;
}
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: baseline; gap: var(--s2); margin-bottom: var(--s3); }
.panel-head h3, .panel-title { font: 600 var(--fs-lg)/1.1 var(--font-display); text-transform: uppercase; letter-spacing: .02em; }
.panel-head .count { font: 400 var(--fs-md)/1 var(--font-display); color: var(--muted); }
.panel-head .grow + a, .panel-head .action { font-size: var(--fs-sm); color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }
.panel-head .action::after { content: ' →'; text-decoration: none; display: inline-block; margin-left: 2px; }
.divider { height: 1px; background: var(--line); margin: var(--s3) 0; border: 0; }
.eyebrow { font: 600 var(--fs-xs)/1 var(--font-display); letter-spacing: .22em; text-transform: uppercase; color: var(--red-ink); }

/* ---- 5. Buttons ------------------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 16px;
  font: 500 14px/1 var(--font-display); text-transform: uppercase; letter-spacing: .05em; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  cursor: pointer; white-space: nowrap; transition: background var(--fast), border-color var(--fast), filter var(--fast), box-shadow var(--fast);
}
.btn:hover { background: var(--surface-3); border-color: #66707c; }
.btn:active { transform: translateY(1px); }
.btn-primary { color: #fff; background: linear-gradient(180deg, #c3232c, #7d151c); border-color: #e0444b; }
.btn-primary:hover { background: linear-gradient(180deg, #db2f39, #8f1820); border-color: #ff6b72; box-shadow: 0 0 16px var(--red-glow); }
.btn-outline { color: #fff; background: rgba(215, 44, 53, .12); border-color: var(--red); }       /* GO · FIGHT · TAKE */
.btn-outline:hover { background: rgba(215, 44, 53, .26); box-shadow: 0 0 12px var(--red-glow); }
.btn-success { color: #d8f5e6; background: var(--green-soft); border-color: var(--green); }           /* CLAIM */
.btn-success:hover { background: rgba(88, 184, 136, .26); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.btn-lg { min-height: 56px; padding: 0 28px; font-size: 20px; letter-spacing: .06em; }
.btn-sm { min-height: 30px; padding: 0 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn:disabled, .btn[aria-disabled="true"], .btn.done {
  cursor: not-allowed; color: #7d858f; background: #1a1f25; border-color: #2f363e; box-shadow: none; filter: none; transform: none;
}
.btn.loading { color: transparent; position: relative; pointer-events: none; }
.btn.loading::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 6. Tabs, segmented, side menu ----------------------------------------------------------- */
.tabs { display: flex; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; background: var(--inset); }
.tabs > * {
  flex: 1 0 auto; padding: 9px 14px; font: 500 13px/1 var(--font-display); text-transform: uppercase; letter-spacing: .05em; text-align: center;
  color: var(--text-2); background: transparent; border: 0; border-left: 1px solid var(--line); cursor: pointer;
}
.tabs > *:first-child { border-left: 0; }
.tabs > *:hover { color: #fff; background: rgba(255, 255, 255, .04); }
.tabs > .active, .tabs > [aria-selected="true"] { color: #fff; background: linear-gradient(180deg, #b0222a, #7d151c); box-shadow: inset 0 0 0 1px #e0444b; }
.tabs.underline { border: 0; background: transparent; border-bottom: 1px solid var(--line); border-radius: 0; }
.tabs.underline > * { border: 0; padding: 14px; font-size: var(--fs-lg); }
.tabs.underline > .active { background: transparent; box-shadow: inset 0 -2px 0 var(--red); }

.menu { display: flex; flex-direction: column; gap: 4px; }
.menu > a, .menu > button {
  display: flex; align-items: center; gap: var(--s3); padding: 11px 14px; border-radius: var(--r-sm);
  font-size: var(--fs-md); color: var(--text-2); background: transparent; border: 1px solid transparent; text-align: left; cursor: pointer;
}
.menu > a svg, .menu > button svg { color: var(--text-2); flex-shrink: 0; }
.menu > a:hover, .menu > button:hover { background: rgba(255, 255, 255, .04); color: #fff; }
.menu > .active { color: #fff; background: linear-gradient(90deg, #7d151c, #4a1016); border-color: var(--red); box-shadow: 0 0 14px rgba(215, 44, 53, .3); }
.menu > .active svg { color: #fff; }

/* ---- 7. Chips, badges, rarity, live ----------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: var(--r-sm);
  font: 500 12px/1 var(--font-display); text-transform: uppercase; letter-spacing: .05em;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line);
}
.chip.red { background: var(--red-soft); color: var(--red-ink); border-color: rgba(215, 44, 53, .5); }
.chip.green { background: var(--green-soft); color: var(--green); border-color: rgba(88, 184, 136, .45); }
.chip.gold { background: rgba(226, 181, 94, .12); color: var(--gold); border-color: rgba(226, 181, 94, .45); }
.chip.club { background: color-mix(in srgb, var(--club) 22%, transparent); color: #fff; border-color: color-mix(in srgb, var(--club) 70%, transparent); }
.live { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: var(--r-sm); font: 600 12px/1 var(--font-display); text-transform: uppercase; letter-spacing: .08em; color: #fff; background: var(--red); }
.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.rarity { display: inline-block; padding: 3px 7px; border-radius: 3px; font: 600 11px/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase; color: #0b0e12; background: var(--rc, var(--r-common)); }
.r-common { --rc: var(--r-common); } .r-uncommon { --rc: var(--r-uncommon); } .r-rare { --rc: var(--r-rare); } .r-epic { --rc: var(--r-epic); } .r-legendary { --rc: var(--r-legendary); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center; font: 600 11px/1 var(--font-body); background: var(--red); color: #fff; }

/* ---- 8. Progress, stats, key-value -------------------------------------------------------------- */
.bar { position: relative; height: 6px; border-radius: 6px; background: #2c323a; overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, #a01b23, #f05c60); transition: width var(--med); }
.bar.lg { height: 10px; } .bar.xl { height: 14px; }
.bar.gold > i { background: linear-gradient(90deg, #926523, #f5c15e); }
.bar.green > i { background: linear-gradient(90deg, #2e7d58, #6fd4a1); }
.bar.blue > i { background: linear-gradient(90deg, #1f5aa6, #5aa6f2); }
.bar-label { display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 5px; font-variant-numeric: tabular-nums; }
/* segmented attribute bar (profile) */
.seg { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; height: 12px; }
.seg > i { background: #2a3038; border-radius: 1px; }
.seg > i.on { background: var(--sc, var(--red)); box-shadow: 0 0 6px color-mix(in srgb, var(--sc, var(--red)) 45%, transparent); }
.stat-line { display: grid; grid-template-columns: 26px 1fr 44px minmax(90px, 160px) 32px; align-items: center; gap: var(--s3); padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.stat-line .ic { color: var(--sc); } .stat-line .name { font-size: var(--fs-md); } .stat-line .val { font: 600 20px/1 var(--font-display); text-align: right; font-variant-numeric: tabular-nums; }
.s-str { --sc: var(--stat-str); } .s-agi { --sc: var(--stat-agi); } .s-con { --sc: var(--stat-con); } .s-ins { --sc: var(--stat-ins); } .s-prs { --sc: var(--stat-prs); } .s-int { --sc: var(--stat-int); }
.kv { display: flex; flex-direction: column; }
.kv > div { display: flex; justify-content: space-between; gap: var(--s3); padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt, .kv .k { color: var(--muted); } .kv dd, .kv .v { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }

/* ---- 9. Player card, crest, avatars -------------------------------------------------------------- */
.player-card { display: flex; gap: var(--s3); align-items: center; }
.crest-box { width: 72px; height: 72px; flex-shrink: 0; display: grid; place-items: center; background: var(--inset); border: 1px solid var(--border-strong); border-radius: var(--r-sm); }
.player-card .name { font: 600 24px/1 var(--font-display); }
.player-card .lvl { font: 500 18px/1 var(--font-display); } .player-card .lvl b { color: var(--red-ink); font-size: 22px; }
.avatar { width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--inset) center top/cover; border: 1px solid var(--line); flex-shrink: 0; }
.rank-no { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 3px; font: 600 14px/1 var(--font-display); color: var(--text-2); }
.rank-no.r1 { background: linear-gradient(180deg, #b48a38, #6d4f17); color: #fff2d2; box-shadow: inset 0 0 0 1px #e2b55e; }
.rank-no.r2 { background: linear-gradient(180deg, #7c838c, #444a51); color: #fff; box-shadow: inset 0 0 0 1px #b4bcc6; }
.rank-no.r3 { background: linear-gradient(180deg, #8a5634, #4d2c18); color: #ffe2cc; box-shadow: inset 0 0 0 1px #c0804f; }

/* ---- 10. Lists: leaderboard, table, tasks, activity -------------------------------------------------- */
.lb { display: flex; flex-direction: column; }
.lb > .lb-row { display: flex; align-items: center; gap: var(--s3); padding: 8px 6px; border-bottom: 1px solid var(--line); }
.lb > .lb-row:last-child { border-bottom: 0; }
.lb .lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-md); }
.lb .lb-val { font: 500 var(--fs-md)/1 var(--font-body); font-variant-numeric: tabular-nums; }
.lb-row.me, .table tr.me { background: linear-gradient(90deg, rgba(215,44,53,.24), rgba(215,44,53,.06)); box-shadow: inset 0 0 0 1px var(--red); }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; padding: 10px 12px; font: 500 12px/1 var(--font-display); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table tr:hover td { background: rgba(255, 255, 255, .02); }
@media (max-width: 640px) { .table.cards thead { display: none; } .table.cards tr { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; padding: 10px; border-bottom: 1px solid var(--line); } .table.cards td { border: 0; padding: 0; } }
.task { display: grid; grid-template-columns: 34px 1fr auto 96px; align-items: center; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .ic { color: var(--text-2); display: grid; place-items: center; }
.task .title { font-size: var(--fs-md); margin-bottom: 6px; }
.task .reward { font: 600 var(--fs-md)/1 var(--font-body); color: var(--gold); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.task .reward.rp { color: var(--warning); }
@media (max-width: 640px) { .item-card .art { height: 120px; } .task { grid-template-columns: 28px 1fr auto; } .task .btn { grid-column: 2 / -1; } }
.activity > div { display: flex; gap: var(--s3); align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.activity time { margin-left: auto; color: var(--muted); white-space: nowrap; }

/* ---- 11. Items: slot, item card, reward tile, inventory grid --------------------------------------- */
.slot {
  position: relative; width: 84px; aspect-ratio: 1; display: grid; place-items: center; padding: 8px;
  background: radial-gradient(circle at 50% 35%, #232a33, var(--inset) 70%); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  cursor: pointer; transition: border-color var(--fast), box-shadow var(--fast);
}
.slot img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0,0,0,.6)); }
.slot .slot-label { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--text-2); text-shadow: 0 1px 2px #000; }
.slot.has-label img { height: 78%; margin-top: -10%; }
.slot:hover { border-color: #7a8490; }
.slot.selected { border-color: var(--red); box-shadow: var(--glow); }
.slot.empty { color: #48505a; font-size: 26px; }
.slot[class*="r-"]:not(.r-common) { border-color: color-mix(in srgb, var(--rc) 70%, #000); box-shadow: inset 0 0 18px color-mix(in srgb, var(--rc) 22%, transparent); }
.slot.locked { opacity: .45; cursor: not-allowed; }
.inventory { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--s2); }
.inventory .slot { width: auto; }
.item-card {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 10px; min-width: 0;
  background: linear-gradient(180deg, #181d24, #101419); border: 1px solid var(--border); border-radius: var(--r-md);
  transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast);
}
.item-card:hover { border-color: #66707c; transform: translateY(-1px); }
.item-card.selected { border-color: var(--red); box-shadow: var(--glow); }
.item-card .art { height: 170px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--rc, #333) 18%, #1d232a), transparent 70%); border-radius: var(--r-sm); }
.item-card .art img { max-width: 88%; max-height: 88%; width: auto; height: auto; filter: drop-shadow(0 8px 10px rgba(0,0,0,.6)); }
.item-card .rarity { position: absolute; top: 8px; left: 8px; }
.item-card .name { font: 500 var(--fs-md)/1.15 var(--font-display); }
.item-card .bonuses { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.35; }
.item-card .bonuses b { color: var(--green); font-weight: 600; }
.item-card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.price { display: inline-flex; align-items: center; gap: 6px; font: 600 var(--fs-md)/1 var(--font-body); font-variant-numeric: tabular-nums; }
.reward-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: var(--s2); }
.reward-grid .slot { width: auto; cursor: default; }
.mystery { font: 600 34px/1 var(--font-display); color: #5b636d; }

/* ---- 12. Hero banners, mode cards, scene cards ----------------------------------------------------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden; min-height: 280px; padding: var(--s6);
  display: flex; flex-direction: column; justify-content: flex-end; gap: var(--s3);
  border: 1px solid #4a3a3e; border-radius: var(--r-lg); background: #15181d center/cover no-repeat;
}
.hero::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(7,9,12,.96), rgba(7,9,12,.15) 70%), linear-gradient(90deg, rgba(7,9,12,.8), transparent 65%); }
.hero-title {
  font: 700 var(--fs-hero)/.92 var(--font-display); text-transform: uppercase; letter-spacing: -.01em;
  transform: skewX(-8deg); transform-origin: left bottom; text-shadow: 0 4px 18px rgba(0,0,0,.8);
}
.hero-title em { font-style: normal; color: var(--red); }
.hero p { max-width: 620px; color: var(--text-2); margin: 0; font-size: var(--fs-md); }
.countdown { display: inline-flex; align-items: center; gap: var(--s3); padding: 8px 14px; background: rgba(7,9,12,.75); border: 1px solid var(--border-strong); border-radius: var(--r-sm); }
.countdown small { font: 500 12px/1 var(--font-display); letter-spacing: .08em; color: var(--text-2); text-transform: uppercase; }
.countdown b { font: 600 24px/1 var(--font-display); color: var(--red-ink); font-variant-numeric: tabular-nums; }
.mode-card {
  position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 92px; overflow: hidden; isolation: isolate; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: #15191e center/cover; cursor: pointer; transition: border-color var(--fast), box-shadow var(--fast);
}
.mode-card::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(7,9,12,.15), rgba(7,9,12,.88) 48%); }
.mode-card .thumb { width: 42%; align-self: stretch; margin: -14px 0 -14px -16px; background: center/cover; }
.mode-card h4 { font-size: var(--fs-xl); text-transform: none; } .mode-card p { margin: 2px 0 0; color: var(--text-2); }
.mode-card:hover { border-color: #737c87; }
.mode-card.active { border-color: var(--red); box-shadow: var(--glow); }
.mode-card.locked { filter: grayscale(.8); opacity: .6; }

/* ---- 13. Match day: VS header, fan power ------------------------------------------------------------ */
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s4); text-align: center; }
.vs .side .crest-xl { width: 96px; height: 96px; margin: 0 auto var(--s2); }
.vs .club-name { font: 700 34px/1 var(--font-display); text-transform: uppercase; }
.vs .club-sub { color: var(--text-2); }
.vs .mid .vs-word { font: 700 56px/1 var(--font-display); color: #f3f5f7; text-shadow: 0 4px 18px #000; }
.vs .mid .kick { font: 500 24px/1.2 var(--font-display); }
.fanpower { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s3); }
.fanpower .pct { font: 700 30px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.fanpower .pct.home { color: var(--club); } .fanpower .pct.away { color: var(--rival); }
.fanpower .track { position: relative; height: 18px; display: flex; border-radius: 10px; overflow: hidden; background: #1b2026; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.fanpower .track > i:first-of-type { background: linear-gradient(90deg, color-mix(in srgb, var(--club) 55%, #000), var(--club)); }
.fanpower .track > i:last-of-type { background: linear-gradient(90deg, var(--rival), color-mix(in srgb, var(--rival) 55%, #000)); }
.fanpower .label { grid-column: 1 / -1; display: flex; justify-content: space-between; color: var(--text-2); font-size: var(--fs-sm); }
.fanpower .title { grid-column: 1 / -1; text-align: center; font: 600 18px/1 var(--font-display); text-transform: uppercase; letter-spacing: .06em; }

/* ---- 14. Character stage (profile hero) --------------------------------------------------------------- */
.stage { position: relative; display: grid; grid-template-columns: 96px 1fr 96px; gap: var(--s3); padding: var(--s4); border-radius: var(--r-lg); overflow: hidden; isolation: isolate; background: #121519 center/cover; border: 1px solid var(--border); min-height: 640px; }
.stage::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(7,9,12,.9), rgba(7,9,12,.2) 45%, rgba(7,9,12,.55)); }
.stage .slots { display: flex; flex-direction: column; gap: var(--s2); justify-content: center; }
.stage .slots .slot { width: 100%; }
.stage .figure { display: flex; align-items: flex-end; justify-content: center; }
.stage .figure img { max-height: 600px; width: auto; filter: drop-shadow(0 18px 24px rgba(0,0,0,.75)); }
@media (max-width: 640px) { .stage { grid-template-columns: 64px 1fr 64px; min-height: 460px; } .stage .figure img { max-height: 420px; } }

/* ---- 15. City map pins, calendar ------------------------------------------------------------------------ */
.map { position: relative; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); background: #0b0d10 center/cover; }
.pin { position: absolute; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; }
.pin .pin-ic { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: rgba(10, 12, 16, .9); border: 1px solid #5a636d; color: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.6); }
.pin .pin-label { padding: 6px 10px; background: rgba(10, 12, 16, .92); border: 1px solid #3c444d; border-radius: var(--r-sm); text-align: center; font: 600 14px/1.1 var(--font-display); text-transform: uppercase; white-space: nowrap; }
.pin .pin-label small { display: block; font: 400 12px/1.2 var(--font-body); color: var(--text-2); text-transform: none; }
.pin.active .pin-ic { background: var(--red); border-color: #ff8a90; box-shadow: 0 0 22px var(--red-glow); }
.pin.active .pin-label { border-color: var(--red); }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.calendar > div { padding: 6px 0; border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text-2); border: 1px solid transparent; }
.calendar > div b { display: block; font: 600 20px/1.1 var(--font-display); color: var(--text); }
.calendar > .today { border-color: var(--red); background: var(--red-soft); color: #fff; }

/* ---- 16. Forms --------------------------------------------------------------------------------------------- */
.field { position: relative; display: flex; align-items: center; }
.field svg { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.input, .select, textarea.input {
  width: 100%; min-height: 44px; padding: 0 14px; font: 400 var(--fs-base)/1.2 var(--font-body); color: var(--text);
  background: var(--inset); border: 1px solid var(--border-strong); border-radius: var(--r-sm); transition: border-color var(--fast), box-shadow var(--fast);
}
.field svg + .input { padding-left: 44px; }
textarea.input { padding: 10px 14px; min-height: 90px; resize: vertical; }
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.input.error { border-color: var(--danger); } .field-error { color: var(--danger); font-size: var(--fs-sm); margin-top: 4px; }
.select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text-2); }
.check input { appearance: none; width: 20px; height: 20px; border: 1px solid var(--border-strong); border-radius: 3px; background: var(--inset); display: grid; place-items: center; margin: 0; }
.check input:checked { background: var(--red); border-color: var(--red); }
.check input:checked::after { content: '✓'; color: #fff; font-size: 13px; }
.or { display: flex; align-items: center; gap: var(--s3); color: var(--muted); font: 500 14px/1 var(--font-display); letter-spacing: .3em; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---- 17. Chat dock ---------------------------------------------------------------------------------------------- */
.chat { display: flex; flex-direction: column; gap: var(--s3); }
.chat-log { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; font-size: var(--fs-base); }
.chat-log time { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }
.chat-log b { font-weight: 600; margin-right: 4px; }
.chat-form { display: flex; gap: var(--s2); }

/* ---- 18. Feedback: toast, tooltip, skeleton, empty, dialog ------------------------------------------------------- */
.toast { display: flex; align-items: center; gap: var(--s3); padding: 12px 16px; min-width: 260px; background: #151a20; border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: var(--r-sm); box-shadow: var(--shadow); }
.toast.error { border-left-color: var(--danger); } .toast.info { border-left-color: var(--info); }
.tooltip { position: relative; }
.tooltip[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); padding: 7px 10px; background: #0c0f13; border: 1px solid var(--border-strong); border-radius: var(--r-sm); font-size: var(--fs-sm); white-space: nowrap; z-index: 10; }
.skeleton { background: linear-gradient(90deg, #1a1f25 25%, #232931 50%, #1a1f25 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); min-height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: var(--s5); text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--r-md); }
.empty svg { color: #48505a; }
.dialog { width: min(440px, calc(100vw - 32px)); padding: var(--s5); background: #13171c; border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: 0 30px 80px rgba(0,0,0,.7); }
.dialog::backdrop { background: rgba(4, 5, 7, .72); backdrop-filter: blur(2px); }

/* reduced motion */
/* OS "reduce motion": calm the UI, but keep the landing marquees running (the game's own "less animation" setting stops them) */
@media (prefers-reduced-motion: reduce) { *:not(.crest-row):not(.ticker-track), *::before, *::after { animation: none !important; transition: none !important; } }

/* Japanese: no tracking — letter-spacing is for Latin capitals and pulls kana apart */
html:lang(ja) * { letter-spacing: 0 !important; }
