/* Shared header: keep its controls in place in legacy and modern mode. */
:root {
  --sb-parchment: #ebd6aa;
  --sb-gold: #d8a94f;
  --sb-gold-light: #f6d887;
  --sb-gold-dark: #79501e;
  --sb-text: #fff0d0;
  --sb-shadow: rgba(39, 20, 5, .45);
}
body .sb-fantasy-header {
  --sb-header-height: 145px;
  --sb-button-height: 38px;
  --sb-button-padding: 12px;
  --sb-button-font: 13px;
  --sb-logo-size: 88px;
  container: sb-header / inline-size;
  box-sizing: border-box;
  background: var(--sb-parchment) url('./supperbull-header-parchment.png') center / 100% 100% no-repeat;
  border: 1px solid var(--sb-gold-dark);
  box-shadow: 0 3px 10px var(--sb-shadow);
  backdrop-filter: none;
  color: #35200f;
  color-scheme: light;
}
/* Keep the parchment in the page flow, behind floating page controls and dialogs. */
body .sb-fantasy-header.topbar {
  display: block;
  position: relative;
  z-index: auto;
  will-change: auto;
}
body .sb-fantasy-header .topbar__inner {
  box-sizing: border-box;
  min-height: var(--sb-header-height);
  max-width: none;
  padding: 10px 20px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 8px 18px;
}
body .sb-fantasy-header .topbar__brand {
  display: flex;
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  gap: 12px;
  color: #291809;
}
body .sb-fantasy-header a.topbar__brand { text-decoration: none; border-radius: 8px; }
body .sb-fantasy-header a.topbar__brand:hover .topbar__logo { filter: drop-shadow(0 3px 2px #79501e55) brightness(1.1); }
body .sb-fantasy-header a.topbar__brand:focus-visible { outline: 3px solid #58270d; outline-offset: 3px; }
body .sb-fantasy-header .topbar__logo {
  display: block;
  width: var(--sb-logo-size);
  height: var(--sb-logo-size);
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 2px #79501e55);
}
body .sb-fantasy-header .topbar__title {
  display: block;
  position: relative;
  padding-bottom: 14px;
  font: bold clamp(20px, 2vw, 30px) Georgia, 'Times New Roman', serif;
  white-space: nowrap;
  text-shadow: 0 1px 1px #fff0d0;
}
body .sb-fantasy-header .topbar__title::before {
  content: '';
  position: absolute;
  inset: auto 0 2px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #79501e, #d8a94f, #79501e, transparent);
}
body .sb-fantasy-header .topbar__title::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: calc(50% - 4px);
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  background: var(--sb-gold);
  border: 1px solid var(--sb-gold-dark);
  box-shadow: 0 0 0 2px #ebd6aa;
}
body .sb-fantasy-header #topbarMenu {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 7px;
  width: auto;
  min-width: 0;
  padding: 0;
  margin: 0;
}
body .sb-fantasy-header .sb-fantasy-nav-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}
body .sb-fantasy-header .sb-fantasy-nav-row:not(:has(> .sb-fantasy-button)) { display: none; }
body .sb-fantasy-header #topbarMenu #topbar-btn-tymczasowy { display: none; }
body .sb-fantasy-header #topbarMenu .sb-fantasy-button {
  --sb-module: #35200f;
  --sb-glow: #d8a94f;
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: auto;
  min-width: 0;
  height: var(--sb-button-height);
  flex: 0 0 auto;
  white-space: nowrap;
  margin: 0;
  padding: 6px var(--sb-button-padding);
  border: 1px solid var(--sb-gold);
  border-radius: 8px;
  background: linear-gradient(165deg, #ffffff18, transparent 42%), linear-gradient(110deg, var(--sb-module), #080603 130%);
  color: var(--sb-text);
  box-shadow: inset 0 0 0 2px #160d05, inset 0 0 0 3px #b88332, inset 0 5px 8px #ffffff0c, 0 3px 5px var(--sb-shadow);
  font: bold var(--sb-button-font)/1.15 Georgia, 'Times New Roman', serif;
  text-align: left;
  text-decoration: none;
  text-shadow: 0 1px 2px #000;
  transition: transform 180ms, box-shadow 180ms, filter 180ms;
}
body .sb-fantasy-header #topbarMenu .sb-fantasy-button::before {
  content: '';
  pointer-events: none;
  position: absolute;
  inset: 5px;
  border: 1px solid #f6d88755;
  clip-path: polygon(0 0, 12px 0, 12px 1px, calc(100% - 12px) 1px, calc(100% - 12px) 0, 100% 0, 100% 8px, calc(100% - 1px) 8px, calc(100% - 1px) calc(100% - 8px), 100% calc(100% - 8px), 100% 100%, calc(100% - 12px) 100%, calc(100% - 12px) calc(100% - 1px), 12px calc(100% - 1px), 12px 100%, 0 100%);
}
body .sb-fantasy-header #topbarMenu .sb-fantasy-button--gemini { --sb-module: #32103f; --sb-glow: #da80f5; }
body .sb-fantasy-header #topbarMenu .sb-fantasy-button--substitutions { --sb-module: #38230f; }
body .sb-fantasy-header #topbarMenu .sb-fantasy-button--attacks { --sb-module: #55140d; --sb-glow: #ff7050; }
body .sb-fantasy-header #topbarMenu .sb-fantasy-button--planner { --sb-module: #12351a; --sb-glow: #8bdb68; }
body .sb-fantasy-header #topbarMenu .sb-fantasy-button--schedules { --sb-module: #092f43; --sb-glow: #6dd4ff; }
body .sb-fantasy-header #topbarMenu .sb-fantasy-button--admin { --sb-module: #291809; }
body .sb-fantasy-header .sb-fantasy-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--sb-gold-light);
  filter: drop-shadow(0 0 4px var(--sb-glow));
}
body .sb-fantasy-header #topbarMenu .sb-fantasy-button__label { flex: 1; }
body .sb-fantasy-header .sb-fantasy-chevron {
  width: 9px;
  height: 16px;
  flex: 0 0 9px;
  fill: none;
  stroke: var(--sb-gold-light);
  stroke-width: 2;
}
body .sb-fantasy-header #topbarMenu .sb-fantasy-button:hover {
  filter: brightness(1.16);
  transform: translateY(-1px);
  border-color: var(--sb-gold-light);
  box-shadow: inset 0 0 0 2px #160d05, inset 0 0 0 3px var(--sb-gold), 0 0 9px color-mix(in srgb, var(--sb-glow) 45%, transparent), 0 4px 6px var(--sb-shadow);
}
body .sb-fantasy-header #topbarMenu .sb-fantasy-button:active { transform: translateY(0); filter: brightness(.93); }
body .sb-fantasy-header #topbarMenu .sb-fantasy-button--active,
body .sb-fantasy-header #topbarMenu .sb-fantasy-button[aria-expanded='true'] {
  border-color: #fff1b9;
  box-shadow: inset 0 0 0 2px #160d05, inset 0 0 0 3px var(--sb-gold-light), 0 0 8px #d8a94f88;
}
body .sb-fantasy-header #topbarMenu .sb-fantasy-button:focus-visible,
body .sb-fantasy-header .topbar__toggle:focus-visible { outline: 3px solid #58270d; outline-offset: 3px; }

body .sb-fantasy-header .topbar__toggle { display: none; }
body .sb-fantasy-header .topbar-meta--inline {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px 16px;
  width: 100%;
  inline-size: auto;
  max-inline-size: none;
  min-width: 0;
  margin: 0;
  padding: 6px 0 0;
  border: 0;
  border-top: 1px solid #79501e44;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #35200f;
  font-size: 11px;
}
body .sb-fantasy-header .topbar-meta--inline:empty { display: none; }
body .sb-fantasy-header .topbar-meta__info,
body .sb-fantasy-header .topbar-meta__selectors,
body .sb-fantasy-header .sb-fantasy-account-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px 12px;
  min-width: 0;
  overflow: visible;
  color: inherit;
  font-size: inherit;
}
body .sb-fantasy-header .topbar-meta__info { margin-right: auto; }
body .sb-fantasy-header .topbar-meta__info > div { flex: 0 1 auto; white-space: normal; overflow-wrap: anywhere; font-size: 12px; }
body .sb-fantasy-header .topbar-meta__info b { margin-right: 3px; }
body .sb-fantasy-header .topbar-meta__account-link,
body .sb-fantasy-header .topbar-meta__logout--inline { padding: 3px 6px; border: 1px solid #79501e66; border-radius: 5px; color: #35200f; background: #fff0d044; font-size: inherit; }
body .sb-fantasy-header .topbar-account-menu { align-self: center; }
body .sb-fantasy-header .topbar-account-menu > summary { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; }
body .sb-fantasy-header .topbar-account-menu > summary img { display: block; object-fit: contain; }
body .sb-fantasy-header .topbar-account-menu > summary .topbar-account-menu__gear--light { display: none; }
body.light-mode .sb-fantasy-header .topbar-account-menu > summary .topbar-account-menu__gear--dark { display: none; }
body.light-mode .sb-fantasy-header .topbar-account-menu > summary .topbar-account-menu__gear--light { display: block; }
body .sb-fantasy-header .topbar-account-menu > summary:hover,
body .sb-fantasy-header .topbar-account-menu[open] > summary { background: transparent; filter: brightness(1.12); }
body .sb-fantasy-header .topbar-account-menu__panel { left: var(--sb-account-menu-left, 0); right: auto; }
body .sb-fantasy-header .theme-switcher { margin: 0; width: auto; gap: 4px; color: inherit; font-size: inherit; }
body .sb-fantasy-header .topbar-meta.topbar-meta--inline .theme-switcher select { min-height: 24px; height: 24px; line-height: normal; flex: 0 1 auto; width: auto; min-width: 0; max-width: 130px; padding: 2px 4px; font-size: 11px; background: #fff0d099; color: #35200f; border-color: #79501e88; }
body .sb-fantasy-header .premium-notice { color: #58401e; font-size: 11px; white-space: normal; overflow: visible; }
body .sb-fantasy-header .premium-notice--warn { color: #794500; }
body .sb-fantasy-header .premium-notice--off { color: #94261b; }
body .sb-fantasy-header .topbar-panels { position: static; padding: 0 16px; }
body .sb-fantasy-header .topbar-panel:not([hidden]) { position: static; margin: 0 0 12px; width: 100%; max-width: none; box-sizing: border-box; }
/* The modern sidebar already provides Start / management navigation. */
body .sb-fantasy-header {
  --sb-button-height: 36px;
  --sb-button-font: 12px;
}
body[data-ui="modern"] .sb-fantasy-header #topbarMenu #topbar-btn-management { display: none; }
body .sb-fantasy-header #topbarMenu {
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}
body .sb-fantasy-header .sb-fantasy-nav-row { display: contents; }
@container sb-header (min-width: 701px) {
  body .sb-fantasy-header .topbar__inner {
    --sb-logo-size: 64px;
    --sb-button-padding: 9px;
    min-height: 120px;
    padding: 8px 16px;
    gap: 6px 14px;
  }
  body .sb-fantasy-header .topbar__title { font-size: 24px; }
}
/* Match the actual available width, including the modern sidebar. */
@container sb-header (max-width: 1100px) {
  body .sb-fantasy-header .topbar__inner { --sb-logo-size: 60px; --sb-button-padding: 10px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; gap: 8px; padding: 10px 16px; }
  body .sb-fantasy-header .topbar__brand { grid-column: 1; grid-row: 1; justify-content: center; }
  body .sb-fantasy-header .topbar__title { font-size: 24px; }
  body .sb-fantasy-header #topbarMenu { grid-column: 1; grid-row: 2; align-items: center; }
  body .sb-fantasy-header .sb-fantasy-nav-row { justify-content: center; }
  body .sb-fantasy-header .topbar-meta--inline { grid-column: 1; grid-row: 3; justify-content: center; }
  body .sb-fantasy-header .topbar-meta__info { margin-right: 0; }
}
@media (max-width: 700px) {
  body .sb-fantasy-header.topbar { position: relative; background-size: auto 100%; }
}
@container sb-header (max-width: 700px) {
  body .sb-fantasy-header .topbar__inner { --sb-logo-size: 50px; min-height: 0; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto; padding: 10px 14px; gap: 10px; }
  body .sb-fantasy-header .topbar__brand { grid-column: 1; grid-row: 1; justify-content: flex-start; gap: 8px; }
  body .sb-fantasy-header .topbar__title { font-size: clamp(16px, 4.5vw, 23px); white-space: normal; }
  body .sb-fantasy-header .topbar__toggle { display: inline-flex; grid-column: 2; grid-row: 1; align-self: center; align-items: center; padding: 9px; color: #35200f; border: 1px solid #79501e; background: #fff0d055; }
  body .sb-fantasy-header #topbarMenu { display: none; grid-column: 1 / -1; grid-row: 3; align-items: stretch; }
  body .sb-fantasy-header #topbarMenu.is-open { display: flex; }
  body .sb-fantasy-header #topbarMenu { flex-direction: column; align-items: stretch; }
  body .sb-fantasy-header .sb-fantasy-nav-row { flex-direction: column; align-items: stretch; }
  body .sb-fantasy-header #topbarMenu .sb-fantasy-button { width: 100%; }
  body .sb-fantasy-header .topbar-meta--inline { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  body .sb-fantasy-header .topbar-meta__info { margin-right: auto; }
  body .sb-fantasy-header .topbar-panel__nav a { min-inline-size: 0; max-inline-size: 100%; }
}
@container sb-header (min-width: 701px) and (max-width: 900px) {
  body:not([data-ui="modern"]) .sb-fantasy-header .topbar__inner { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto; min-height: 0; }
  body:not([data-ui="modern"]) .sb-fantasy-header .topbar__brand { grid-column: 1; grid-row: 1; justify-content: flex-start; }
  body:not([data-ui="modern"]) .sb-fantasy-header .topbar__toggle { display: inline-flex; grid-column: 2; grid-row: 1; align-self: center; padding: 9px; color: #35200f; border-color: #79501e; }
  body:not([data-ui="modern"]) .sb-fantasy-header #topbarMenu { display: none; grid-column: 1 / -1; grid-row: 3; flex-direction: column; align-items: stretch; }
  body:not([data-ui="modern"]) .sb-fantasy-header #topbarMenu.is-open { display: flex; }
  body:not([data-ui="modern"]) .sb-fantasy-header #topbarMenu .sb-fantasy-button { width: 100%; }
  body:not([data-ui="modern"]) .sb-fantasy-header .topbar-meta--inline { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  body .sb-fantasy-header #topbarMenu .sb-fantasy-button { transition: none; }
  body .sb-fantasy-header #topbarMenu .sb-fantasy-button:hover { transform: none; }
}

/* Ciemne motywy (bez light-mode): nocna wersja nagłówka; pergamin zostaje dla tribes i green-light. */
body:not(.light-mode) .sb-fantasy-header {
  --sb-night-text: #d9d2c3;
  background: #0b111d url('./supperbull-header-night.jpg') center 58% / cover no-repeat;
  border: 1px solid #a8803f;
  box-shadow: inset 0 0 0 3px #0b111d, inset 0 0 0 4px #d8a94f55, 0 3px 12px #000a;
  color: var(--sb-night-text);
  color-scheme: dark;
}
body:not(.light-mode) .sb-fantasy-header::before {
  content: '';
  pointer-events: none;
  position: absolute;
  inset: 4px;
  --c: #d8a94f;
  background:
    linear-gradient(var(--c), var(--c)) top left / 22px 2px, linear-gradient(var(--c), var(--c)) top left / 2px 22px,
    linear-gradient(var(--c), var(--c)) top right / 22px 2px, linear-gradient(var(--c), var(--c)) top right / 2px 22px,
    linear-gradient(var(--c), var(--c)) bottom left / 22px 2px, linear-gradient(var(--c), var(--c)) bottom left / 2px 22px,
    linear-gradient(var(--c), var(--c)) bottom right / 22px 2px, linear-gradient(var(--c), var(--c)) bottom right / 2px 22px;
  background-repeat: no-repeat;
}
body:not(.light-mode) .sb-fantasy-header .topbar__brand { color: #f3d9a0; }
body:not(.light-mode) .sb-fantasy-header .topbar__logo { filter: drop-shadow(0 3px 4px #000c); }
body:not(.light-mode) .sb-fantasy-header a.topbar__brand:hover .topbar__logo { filter: drop-shadow(0 0 6px #d8a94f88) brightness(1.1); }
body:not(.light-mode) .sb-fantasy-header .topbar__title {
  background: linear-gradient(180deg, #fbe7b5, #d8a94f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 2px 2px #000b);
}
body:not(.light-mode) .sb-fantasy-header .topbar__title::before { background: linear-gradient(90deg, transparent, #a8803f, #f6d887, #a8803f, transparent); }
body:not(.light-mode) .sb-fantasy-header .topbar__title::after { background: #0b111d; border-color: var(--sb-gold); box-shadow: 0 0 0 2px #0b111d; }
body:not(.light-mode) .sb-fantasy-header .topbar-meta--inline { color: var(--sb-night-text); border-top-color: #d8a94f33; }
body:not(.light-mode) .sb-fantasy-header .topbar-meta__info b { font-weight: normal; color: #a59d8f; }
body:not(.light-mode) .sb-fantasy-header .topbar-meta__world-inline { padding-left: 12px; border-left: 1px solid #d8a94f44; }
body:not(.light-mode) .sb-fantasy-header .topbar-account-menu__panel { background: #0f1726; border: 1px solid #a8803f; }
body:not(.light-mode) .sb-fantasy-header .topbar-meta__account-link,
body:not(.light-mode) .sb-fantasy-header .topbar-meta__logout--inline { color: var(--sb-text); background: #ffffff0a; border-color: #d8a94f66; }
body:not(.light-mode) .sb-fantasy-header .topbar-meta.topbar-meta--inline .theme-switcher label { color: var(--sb-night-text); }
body:not(.light-mode) .sb-fantasy-header .topbar-meta.topbar-meta--inline .theme-switcher select { min-height: 28px; height: 28px; padding: 2px 10px; border-radius: 999px; background-color: #0d1422cc; color: #eae3d4; border-color: #d8a94f; }
body:not(.light-mode) .sb-fantasy-header .topbar-meta__selectors .time-switcher { padding-left: 12px; border-left: 1px solid #d8a94f44; }
body:not(.light-mode) .sb-fantasy-header .premium-notice { color: #c9b98f; }
body:not(.light-mode) .sb-fantasy-header .premium-notice--warn { color: #f0b860; }
body:not(.light-mode) .sb-fantasy-header .premium-notice--off { color: #ff8a7a; }
body:not(.light-mode) .sb-fantasy-header .topbar__toggle { color: var(--sb-gold-light); border: 1px solid #a8803f; background: #0d1422cc; }
body:not(.light-mode) .sb-fantasy-header #topbarMenu .sb-fantasy-button:focus-visible,
body:not(.light-mode) .sb-fantasy-header .topbar__toggle:focus-visible,
body:not(.light-mode) .sb-fantasy-header a.topbar__brand:focus-visible { outline-color: var(--sb-gold-light); }
@media (max-width: 700px) {
  body:not(.light-mode) .sb-fantasy-header.topbar { background-size: cover; }
}

/* Przycisk „Załóż plemię” na prawo od zębatki (prowadzi do strony Premium).
   Obrazek: core/zaloz-plemie.png; bez pliku - złoty przycisk tekstowy. */
.sb-tribe-cta { display: inline-flex; align-items: center; align-self: center; flex: none; margin-left: 6px; text-decoration: none; transition: transform .15s, filter .2s; }
.sb-tribe-cta img { display: block; height: 36px; width: auto; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .45)); }
.sb-tribe-cta:hover { transform: translateY(-1px); filter: brightness(1.08); }
.sb-tribe-cta__text { display: none; }
.sb-tribe-cta--text .sb-tribe-cta__text { display: inline-block; padding: 6px 12px; border: 2px solid #5a3b10; border-radius: 5px; background: linear-gradient(180deg, #f6d88c 0%, #e2ab4d 48%, #c68a31 100%); color: #1f1407; font: 700 14px/1 "Cormorant Garamond", Georgia, serif; white-space: nowrap; box-shadow: inset 0 0 0 1px rgba(255, 236, 190, .55); }
@media (max-width: 760px) {
  .sb-tribe-cta img { height: 28px; }
  .sb-tribe-cta--text .sb-tribe-cta__text { padding: 5px 8px; font-size: 12px; }
}
