@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url(/fonts/cinzel-latin.woff2) format("woff2");
}

@property --angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }

:root {
  color-scheme: dark;
  --bg: #0b101b;
  --surface: #161d2e;
  --surface-alt: #1e2740;
  --border: #2a3550;
  --text: #e7ecf7;
  --muted: #93a0bd;
  --accent: #f2b53c;
  --danger: #e5484d;
  --success: #46b571;

  --gold-hi: #ffe08a;
  --gold-lo: #a8721a;
  --ember: #ff7a3d;
  --silver: #cfd8e8;
  --bronze: #d08a55;
  --glass: rgba(22, 29, 46, 0.62);
  --display: "Cinzel", "Trajan Pro", Georgia, "Times New Roman", serif;

  /* Reserved status colors (KvK win/loss/draw badges) -- never reused for
     a generic series. */
  --status-good: #0ca30c;
  --status-critical: #d03b3b;
  --status-warning: #fab219;

  /* Categorical chart slots 1-3 (dark steps of the reference palette,
     validated all-pairs against --surface). Only ever three series in one
     chart; the remainder folds into --rest. */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --rest: #3a4665;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  scrollbar-color: var(--border) transparent;
}

body {
  margin: 0;
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

::selection { background: rgba(242, 181, 60, 0.35); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Ambient background: drifting aurora + film grain ---------- */

body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 20% 20%, rgba(242, 181, 60, 0.13), transparent 70%),
    radial-gradient(35% 40% at 80% 25%, rgba(57, 135, 229, 0.12), transparent 70%),
    radial-gradient(45% 40% at 60% 85%, rgba(255, 122, 61, 0.08), transparent 70%);
  animation: aurora 38s ease-in-out infinite alternate;
  will-change: transform;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

@keyframes aurora {
  from { transform: translate3d(-3%, -2%, 0) rotate(0deg) scale(1); }
  to   { transform: translate3d(3%, 4%, 0) rotate(8deg) scale(1.12); }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Thin gold progress bar tied to page scroll (browsers without
   scroll-driven animations simply don't show it). */
.scroll-progress { display: none; }

@supports (animation-timeline: scroll()) {
  .scroll-progress {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 100;
    transform-origin: 0 50%;
    transform: scaleX(0);
    background: linear-gradient(90deg, var(--gold-lo), var(--accent), var(--gold-hi));
    box-shadow: 0 0 10px rgba(242, 181, 60, 0.7);
    animation: progress linear forwards;
    animation-timeline: scroll(root);
  }
  @keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}

/* ---------- Header ---------- */

.site-header {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(11, 16, 27, 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-right: 24px;
}
.site-header .brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; color: var(--accent); filter: drop-shadow(0 0 6px rgba(242, 181, 60, 0.6)); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px 20px;
  flex-wrap: wrap;
}

.site-nav a { padding: 6px 2px; color: var(--muted); position: relative; transition: color 0.2s; }
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a:hover::after { transform: scaleX(1); }

/* Account block (admin header): visually separated from the page links. */
.account {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding-left: 20px;
  border-left: 1px solid var(--border);
}

.account .link-button { padding: 6px 0; }

/* Hamburger toggle: hidden checkbox driving a CSS-only mobile menu, no JS. */
.nav-toggle { display: none; }

.nav-toggle-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  margin-left: auto;
  cursor: pointer;
}

.nav-toggle-btn span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

@media (max-width: 700px) {
  .site-header { flex-wrap: wrap; }

  .nav-toggle-btn { display: flex; }

  .site-nav {
    flex-basis: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  .nav-toggle:checked ~ .site-nav { display: flex; }

  .site-nav a { padding: 10px 4px; }

  .account {
    margin-left: 0;
    margin-top: 8px;
    padding-left: 0;
    padding-top: 10px;
    border-left: none;
    border-top: 1px solid var(--border);
    justify-content: space-between;
  }
}

.container {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}

.container.narrow {
  max-width: 400px;
  padding-top: 64px;
}

/* ---------- Scroll reveal (progressive: only hides content once JS is
   confirmed running, and un-hides after 3s if fx.js never loaded) ---------- */

.js .reveal { opacity: 0; }
.js .reveal.in {
  opacity: 1;
  animation: rise 0.75s cubic-bezier(0.2, 0.7, 0.2, 1) calc(var(--i, 0) * 70ms) both;
}
.js.no-fx .reveal { opacity: 1; }

@keyframes rise { from { opacity: 0; translate: 0 24px; } to { opacity: 1; translate: 0 0; } }

/* ---------- Spotlight + shine shared by all interactive cards ---------- */

.stat, .champion-card, .pulse-card, .kvk-history-item { position: relative; }

.stat::after, .champion-card::after, .pulse-card::after, .kvk-history-item::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), rgba(242, 181, 60, 0.16), transparent 65%);
}
.stat:hover::after, .champion-card:hover::after, .pulse-card:hover::after, .kvk-history-item:hover::after { opacity: 1; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  margin-bottom: 32px;
  padding: 48px 36px 40px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background:
    radial-gradient(circle at 12% -20%, rgba(242, 181, 60, 0.2), transparent 55%),
    radial-gradient(circle at 100% 0%, rgba(57, 135, 229, 0.12), transparent 50%),
    linear-gradient(180deg, rgba(22, 29, 46, 0.85), rgba(11, 16, 27, 0.6));
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Rotating gold sheen traced around the hero's border. */
.hero::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: conic-gradient(from var(--angle), transparent 0 55%, rgba(242, 181, 60, 0.9) 78%, var(--gold-hi) 82%, transparent 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: spin 7s linear infinite;
}

@keyframes spin { to { --angle: 360deg; } }

.hero > :not(.hero-bg) { position: relative; z-index: 1; }

/* Rising embers (pure CSS, positions/timings generated in the template). */
.hero-bg {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

.hero-bg i {
  position: absolute;
  bottom: -10px;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-hi), var(--ember) 60%, transparent 70%);
  box-shadow: 0 0 8px 1px rgba(255, 140, 60, 0.8);
  opacity: 0;
  animation: ember var(--d) linear var(--delay) infinite;
}

@keyframes ember {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0; }
  12%  { opacity: 0.9; }
  100% { transform: translate3d(var(--dx), -420px, 0) scale(0.2); opacity: 0; }
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}

.hero h1 {
  margin: 0 0 16px;
  font-family: var(--display);
  font-size: clamp(2.3rem, 7vw, 3.8rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.05;
  background: linear-gradient(100deg, var(--gold-lo) 10%, var(--gold-hi) 35%, var(--accent) 50%, var(--gold-hi) 65%, var(--gold-lo) 90%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmer 7s linear infinite;
  filter: drop-shadow(0 4px 24px rgba(242, 181, 60, 0.25));
}

@keyframes shimmer { to { background-position: -220% center; } }

.hero-copy {
  max-width: 640px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
  margin: 0 0 24px;
}

.hero > .hero-actions { z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }

.cta {
  position: relative;
  overflow: hidden;
  display: inline-block;
  background: linear-gradient(135deg, var(--gold-hi), var(--accent) 45%, var(--gold-lo));
  color: #1a1300;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 13px 24px;
  border-radius: 10px;
  box-shadow: 0 8px 26px -8px rgba(242, 181, 60, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.cta::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.55) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: sweep 4.5s ease-in-out 1.5s infinite;
}
@keyframes sweep { 0%, 55% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.cta:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 14px 34px -8px rgba(242, 181, 60, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.cta:active { transform: translateY(0); }

/* ---------- Governor search (shown by fx.js) ---------- */

.search { position: relative; flex: 1 1 260px; max-width: 360px; }
.search[hidden] { display: none; }

.search input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(30, 39, 64, 0.6);
  color: var(--text);
  font: inherit;
  font-size: max(16px, 1rem);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242, 181, 60, 0.18); }
.search-icon { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }

.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(16, 22, 36, 0.96);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 50px -12px rgba(0, 0, 0, 0.8);
}
.search-results[hidden] { display: none; }

.search-results a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
}
.search-results a:hover, .search-results a[aria-selected="true"] { background: var(--surface-alt); text-decoration: none; }
.search-results img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-alt); }
.search-results .sr-name { font-weight: 600; }
.search-results .sr-meta { margin-left: auto; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.search-empty { padding: 12px; color: var(--muted); }

/* ---------- Stats ---------- */

.player-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.player-hero .avatar {
  border-radius: 16px;
  object-fit: cover;
  background: var(--surface-alt);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(242, 181, 60, 0.15), 0 0 30px rgba(242, 181, 60, 0.35);
}
.player-hero h1 { margin-bottom: 4px; }
.alliance-hero-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.alliance-hero-title img { width: 48px; height: 48px; filter: drop-shadow(0 0 12px rgba(242, 181, 60, 0.4)); }
.muted { color: var(--muted); margin: 4px 0 0; }

.back-link { display: inline-block; margin-bottom: 14px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 24px 0 16px;
}

.stat {
  background: linear-gradient(160deg, rgba(30, 39, 64, 0.75), rgba(22, 29, 46, 0.55));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.stat:hover { transform: translateY(-3px); border-color: rgba(242, 181, 60, 0.45); }

.stat .label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; }
.stat .value { font-family: var(--display); font-size: 1.7rem; font-weight: 700; letter-spacing: 0.02em; }

.trend {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.trend.up { background: rgba(12, 163, 12, 0.15); color: #43d16a; }
.trend.down { background: rgba(208, 59, 59, 0.16); color: #ff7b7b; }

.synced-note { color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }
.synced-note::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--status-good);
  box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.6);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse { to { box-shadow: 0 0 0 9px rgba(12, 163, 12, 0); } }

section { margin-bottom: 44px; }

h2 {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
h2::before {
  content: "";
  width: 5px;
  height: 1.05em;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  box-shadow: 0 0 12px rgba(242, 181, 60, 0.6);
}
h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }

/* ---------- Champions: podium ---------- */

.champion-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  perspective: 900px;
}

.champion-card {
  --tone: #5c6b8f;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  overflow: hidden;
  background: linear-gradient(170deg, rgba(30, 39, 64, 0.85), rgba(22, 29, 46, 0.6));
  border: 1px solid color-mix(in srgb, var(--tone) 55%, transparent);
  border-radius: 14px;
  padding: 24px 14px 18px;
  color: var(--text);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.15s ease-out, border-color 0.2s ease, box-shadow 0.3s ease;
}
.champion-card:hover {
  text-decoration: none;
  border-color: var(--tone);
  box-shadow: 0 18px 40px -16px color-mix(in srgb, var(--tone) 70%, transparent);
}

/* Diagonal shine that sweeps across on hover. */
.champion-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.14) 50%, transparent 60%);
  transform: translateX(-130%);
  transition: transform 0.7s ease;
}
.champion-card:hover::before { transform: translateX(130%); }

.rank-1 { --tone: var(--accent); padding-top: 34px; padding-bottom: 26px; }
.rank-2 { --tone: var(--silver); padding-top: 28px; }
.rank-3 { --tone: var(--bronze); }
/* Podium order on wide screens: 4 · 2 · 1 · 3 · 5 */
.rank-1 { order: 3; }
.rank-2 { order: 2; }
.rank-3 { order: 4; }
.rank-4 { order: 1; }
.rank-5 { order: 5; }

.rank-1 { background: linear-gradient(170deg, rgba(60, 46, 16, 0.9), rgba(22, 29, 46, 0.7)); }

/* Rotating gold ring around the #1 champion. */
.glow-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  pointer-events: none;
  background: conic-gradient(from var(--angle), var(--gold-lo), var(--gold-hi), var(--gold-lo), var(--gold-hi), var(--gold-lo));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: spin 5s linear infinite;
}

.crown { width: 30px; height: 30px; color: var(--accent); filter: drop-shadow(0 0 8px rgba(242, 181, 60, 0.8)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }

.champion-rank {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--tone);
  color: #10131c;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 2px 9px;
}

.champion-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-alt);
  border: 2px solid var(--tone);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 20%, transparent), 0 0 24px color-mix(in srgb, var(--tone) 45%, transparent);
  margin-bottom: 4px;
}
.rank-1 .champion-avatar { width: 84px; height: 84px; }

.champion-name { font-weight: 700; overflow-wrap: anywhere; }
.champion-alliance { color: var(--muted); font-size: 0.85rem; }
.champion-power { color: var(--tone); font-size: 0.9rem; font-weight: 700; }
.rank-4 .champion-power, .rank-5 .champion-power { color: var(--silver); }

@media (max-width: 860px) {
  .champion-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .champion-card { order: 0 !important; }
  .rank-1 { grid-column: 1 / -1; }
}

/* ---------- Kingdom Pulse ---------- */

.pulse-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 14px;
}

.pulse-card {
  border-radius: 14px;
  padding: 20px 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(160deg, rgba(30, 39, 64, 0.7), rgba(22, 29, 46, 0.5));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: border-color 0.2s ease;
}
.pulse-card:hover { border-color: rgba(242, 181, 60, 0.35); }
.pulse-card h3 { margin: 0 0 14px; font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.pulse-wide { grid-column: 1 / -1; }

.pulse-minis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.mini-value { font-family: var(--display); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.mini-sub { margin: 6px 0 0; color: var(--muted); font-size: 0.85rem; }
.mini-value small { font-size: 0.9rem; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; }

/* Town Center tier list */
.tier-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tier-list li { display: grid; grid-template-columns: 44px minmax(0, 1fr) 36px; align-items: center; gap: 12px; }
.tier-list .tg-badge { text-align: center; }
.tier-bar { height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.tier-bar i {
  display: block;
  height: 100%;
  width: var(--w);
  border-radius: 6px;
  background: linear-gradient(90deg, var(--gold-lo), var(--accent) 60%, var(--gold-hi));
  transform-origin: left;
  transition: transform 1s cubic-bezier(0.2, 0.7, 0.2, 1) calc(var(--i, 0) * 90ms);
}
.js .reveal:not(.in) .tier-bar i { transform: scaleX(0); }
.tier-count { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.tier-list + .mini-sub { margin: 0; }

/* Alliance power-share donut */
.donut-layout { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.donut { position: relative; width: 190px; height: 190px; flex-shrink: 0; margin: 0 auto; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.donut circle { fill: none; stroke-width: 5.5; transition: opacity 0.2s, stroke-dasharray 1.3s cubic-bezier(0.2, 0.7, 0.2, 1) 0.15s; }
.slice-1 { stroke: var(--series-1); }
.slice-2 { stroke: var(--series-2); }
.slice-3 { stroke: var(--series-3); }
.slice-rest { stroke: var(--rest); }
.js .reveal:not(.in) .donut circle { stroke-dasharray: 0 100 !important; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center strong { font-family: var(--display); font-size: 2rem; line-height: 1; }
.donut-center span { color: var(--muted); font-size: 0.75rem; max-width: 90px; margin-top: 4px; }

.legend { flex: 1 1 240px; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.legend li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}
.legend li:hover { background: rgba(255, 255, 255, 0.05); }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; }
.legend .l-name { font-weight: 600; }
.legend .l-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.legend .l-sub { grid-column: 2 / -1; color: var(--muted); font-size: 0.8rem; margin-top: -4px; }
.sw-1 { background: var(--series-1); }
.sw-2 { background: var(--series-2); }
.sw-3 { background: var(--series-3); }
.sw-rest { background: var(--rest); }

/* Hovering a legend row dims the other slices (no JS). */
.donut-layout:has(.legend li:nth-child(1):hover) .donut circle:not(.slice-1),
.donut-layout:has(.legend li:nth-child(2):hover) .donut circle:not(.slice-2),
.donut-layout:has(.legend li:nth-child(3):hover) .donut circle:not(.slice-3),
.donut-layout:has(.legend li:nth-child(4):hover) .donut circle:not(.slice-rest) { opacity: 0.25; }

/* Power-bracket histogram */
.hist { display: flex; align-items: flex-end; gap: 10px; }
.hist-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; min-width: 0; }
.hist-bar {
  width: 100%;
  height: calc(var(--frac) * 150px);
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--gold-hi), var(--accent) 40%, var(--gold-lo));
  box-shadow: 0 0 18px rgba(242, 181, 60, 0.25);
  transform-origin: bottom;
  transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) calc(var(--i, 0) * 90ms), filter 0.2s;
}
.js .reveal:not(.in) .hist-bar { transform: scaleY(0); }
.hist-col:hover .hist-bar { filter: brightness(1.2); }
.hist-count { font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.hist-label { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.hist-note { margin: 14px 0 0; color: var(--muted); font-size: 0.85rem; }

@media (max-width: 800px) {
  .pulse-grid { grid-template-columns: minmax(0, 1fr); }
  .pulse-minis { grid-template-columns: minmax(0, 1fr); }
  .hist { gap: 6px; }
  .hist-label { font-size: 0.68rem; }
}

/* ---------- KvK history: timeline ---------- */

.kvk-history-list {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0 0 0 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.kvk-history-list::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--border) 45%, transparent);
}

.kvk-history-item {
  --c: var(--status-warning);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: linear-gradient(160deg, rgba(30, 39, 64, 0.7), rgba(22, 29, 46, 0.5));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.kvk-history-item.is-win { --c: var(--status-good); }
.kvk-history-item.is-loss { --c: var(--status-critical); }
.kvk-history-item.is-split { --c: var(--status-warning); }
.kvk-history-item:hover { transform: translateX(4px); border-color: color-mix(in srgb, var(--c) 60%, transparent); }

/* Timeline node */
.kvk-history-item::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 19px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 4px var(--bg), 0 0 14px var(--c);
}
/* Split result (won one phase, lost the other): half-green, half-red node. */
.kvk-history-item.is-split::before {
  background: linear-gradient(90deg, var(--status-good) 50%, var(--status-critical) 50%);
  box-shadow: 0 0 0 4px var(--bg), 0 0 14px rgba(250, 178, 25, 0.7);
}

.result-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
/* icon + label so the outcome is never color-alone */
.result-win::before { content: "\2713\00a0"; }
.result-loss::before { content: "\2715\00a0"; }
.result-draw::before { content: "\2248\00a0"; }
.result-split::before { content: "\25D0\00a0"; }
.result-win { background: rgba(12, 163, 12, 0.16); color: #43d16a; }
.result-loss { background: rgba(208, 59, 59, 0.16); color: #ff7b7b; }
.result-draw, .result-split { background: rgba(250, 178, 25, 0.16); color: var(--status-warning); }

.kvk-history-body { flex: 1; }

/* Prep / Castle outcome chips: shows a split (one won, one lost) at a glance. */
.phases { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.phase {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.phase-won { background: rgba(12, 163, 12, 0.14); color: #43d16a; border-color: rgba(12, 163, 12, 0.35); }
.phase-lost { background: rgba(208, 59, 59, 0.16); color: #ff7b7b; border-color: rgba(208, 59, 59, 0.4); }
.phase-other { background: rgba(255, 255, 255, 0.06); color: var(--muted); border-color: var(--border); }
.kvk-history-season { font-weight: 700; }
.kvk-history-summary { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.kvk-history-date { font-size: 0.8rem; white-space: nowrap; }

@media (max-width: 560px) {
  .hero { padding: 32px 20px 28px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 14px; }
  .stat .value { font-size: 1.4rem; }
  .kvk-history-item { flex-direction: column; }
  .kvk-history-list { padding-left: 26px; }
  .kvk-history-item::before { left: -24px; }
}

/* ---------- Tables ---------- */

/* Scroll wrapper around the actual <table> -- keeps thead/tbody as ONE real
   table (so column widths stay in sync between header and rows) while still
   letting it scroll horizontally on narrow screens instead of clipping. */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(160deg, rgba(30, 39, 64, 0.5), rgba(22, 29, 46, 0.35));
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; background: rgba(0, 0, 0, 0.18); }
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: rgba(242, 181, 60, 0.06); }
.data-table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* Medal-colored ranks */
.rank-cell { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.top-1 .rank-cell { color: var(--accent); text-shadow: 0 0 10px rgba(242, 181, 60, 0.6); }
.top-2 .rank-cell { color: var(--silver); }
.top-3 .rank-cell { color: var(--bronze); }

/* Power cell: value on top of a proportional bar. */
.power-cell { position: relative; min-width: 150px; font-weight: 600; font-variant-numeric: tabular-nums; }
.power-cell::before {
  content: "";
  position: absolute;
  inset: 7px auto 7px 0;
  width: var(--w);
  border-radius: 0 6px 6px 0;
  background: linear-gradient(90deg, rgba(242, 181, 60, 0.04), rgba(242, 181, 60, 0.32));
  border-right: 2px solid rgba(242, 181, 60, 0.75);
  transform-origin: left;
  transition: transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) calc(var(--i, 0) * 45ms);
}
.js .reveal:not(.in) .power-cell::before { transform: scaleX(0); }
.power-cell span { position: relative; }

.tag-cell { display: flex; align-items: center; gap: 8px; }
.flag { width: 24px; height: 24px; object-fit: contain; }

.tg-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #1a1300;
  background: linear-gradient(135deg, var(--gold-hi), var(--accent));
  box-shadow: 0 0 10px rgba(242, 181, 60, 0.35);
}

/* ---------- Admin / shared components ---------- */

.app-list { display: flex; flex-direction: column; gap: 10px; }

.app-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 16px;
}

.app-item summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.app-item summary::-webkit-details-marker { display: none; }
.app-item summary::after { content: "\25BE"; color: var(--muted); margin-left: 12px; }
.app-item[open] summary::after { content: "\25B4"; }

.app-name { font-weight: 700; }
.app-meta { color: var(--muted); font-size: 0.85rem; }

.app-details {
  padding: 4px 0 18px;
  border-top: 1px solid var(--border);
}

.app-details dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 16px 0;
  font-size: 0.9rem;
}

.app-details dt { color: var(--muted); }
.app-details dd { margin: 0; }

.app-message {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  white-space: pre-wrap;
  margin: 0 0 16px;
}

.form { display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.form input, .form textarea, .form select {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  width: 100%;
  /* 16px prevents iOS Safari from auto-zooming in on focus */
  font-size: max(16px, 1rem);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form input:focus, .form textarea:focus, .form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(242, 181, 60, 0.18);
}
.form button, button[type="submit"] {
  background: linear-gradient(135deg, var(--gold-hi), var(--accent) 50%, var(--gold-lo));
  color: #1a1300;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-weight: 700;
  cursor: pointer;
  width: fit-content;
  min-height: 44px;
  transition: transform 0.15s, filter 0.15s;
}
.form button:hover, button[type="submit"]:hover { transform: translateY(-1px); filter: brightness(1.08); }

.success-box, .error-box {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.success-box { background: rgba(70, 181, 113, 0.15); border: 1px solid var(--success); color: var(--success); }
.error-box { background: rgba(229, 72, 77, 0.15); border: 1px solid var(--danger); color: var(--danger); }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.tabs a {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  display: inline-block;
}
.tabs a.active { background: var(--accent); color: #1a1300; border-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.inline-form { display: inline-flex; margin: 0; }
.link-button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  padding: 8px 0;
  font: inherit;
  width: auto;
}
.approve, .reject {
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  min-height: 40px;
  cursor: pointer;
  font-weight: 600;
}
.approve { background: var(--success); color: #04170c; }
.reject { background: var(--danger); color: #200404; }

/* ---------- Transfer application ---------- */

.apply-hero { padding: 40px 36px 34px; }
.apply-hero h1 { margin-bottom: 12px; }
.apply-hero .hero-copy { margin-bottom: 0; }

.apply-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.apply-form { padding: 28px; display: flex; flex-direction: column; gap: 20px; }
.apply-form .error-box { margin: 0; }
.apply-legend { margin: 0; color: var(--muted); font-size: 0.85rem; }

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.req { color: var(--accent); font-weight: 800; }

.input-wrap { position: relative; }
.input-wrap svg { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; transition: color 0.2s; }
.input-wrap:focus-within svg { color: var(--accent); }

.field input, .field textarea {
  width: 100%;
  padding: 13px 14px 13px 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(30, 39, 64, 0.55);
  color: var(--text);
  font: inherit;
  font-size: max(16px, 1rem);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.field textarea { padding-left: 14px; resize: vertical; min-height: 130px; line-height: 1.5; }
.field input::placeholder, .field textarea::placeholder { color: rgba(147, 160, 189, 0.55); }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(30, 39, 64, 0.85);
  box-shadow: 0 0 0 3px rgba(242, 181, 60, 0.18);
}

/* Validation: server-rendered errors always; live states only after the
   visitor has interacted (:user-invalid / :user-valid). */
.field.has-error input, .field.has-error textarea, .field input:user-invalid, .field textarea:user-invalid {
  border-color: var(--status-critical);
  box-shadow: 0 0 0 3px rgba(208, 59, 59, 0.15);
}
.field input:user-valid, .field textarea:user-valid { border-color: rgba(12, 163, 12, 0.55); }

.field-hint, .field-error { margin: 0; font-size: 0.8rem; }
.field-hint { color: var(--muted); }
.field-error { color: #ff7b7b; font-weight: 600; }
.field-error::before { content: "\2715\00a0"; }

.apply-form .apply-submit {
  width: 100%;
  min-height: 52px;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.apply-submit svg { width: 20px; height: 20px; transition: transform 0.2s; }
.apply-submit:hover svg { transform: translateX(4px); }
.apply-submit[disabled] { opacity: 0.7; cursor: progress; }

.apply-steps ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; position: relative; }
.apply-steps li:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: -20px; width: 2px; background: linear-gradient(180deg, var(--accent), var(--border)); }
.apply-steps li { display: flex; gap: 14px; position: relative; }
.apply-steps p { margin: 2px 0 0; color: var(--muted); font-size: 0.88rem; }
.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 800;
  color: #1a1300;
  background: linear-gradient(135deg, var(--gold-hi), var(--accent));
  box-shadow: 0 0 0 4px var(--bg), 0 0 16px rgba(242, 181, 60, 0.4);
}

.apply-success {
  max-width: 520px;
  margin: 0 auto 44px;
  padding: 40px 32px;
  text-align: center;
  border-radius: 20px;
  border: 1px solid rgba(12, 163, 12, 0.35);
  background: linear-gradient(160deg, rgba(12, 60, 30, 0.35), rgba(22, 29, 46, 0.6));
  box-shadow: 0 0 60px -20px rgba(12, 163, 12, 0.5);
}
.apply-success h2 { justify-content: center; }
.apply-success h2::before, .apply-success h2::after { display: none; }
.apply-success p { color: var(--muted); margin: 0 0 22px; }
.apply-success .check { width: 84px; height: 84px; margin-bottom: 8px; fill: none; stroke: #43d16a; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 12px rgba(67, 209, 106, 0.6)); }
.apply-success .check circle { stroke-dasharray: 145; stroke-dashoffset: 145; animation: draw 0.8s ease-out 0.2s forwards; }
.apply-success .check path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.5s ease-out 0.8s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

@media (max-width: 800px) {
  .apply-layout { grid-template-columns: minmax(0, 1fr); }
  .field-row { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .apply-form { padding: 20px; }
  .apply-hero { padding: 30px 20px 26px; }
}

/* ---------- Reduced motion: keep everything, drop the movement ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    transition-delay: 0s !important;
  }
  .hero-bg { display: none; }
  .champion-card { transform: none !important; }
}
