:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-raised: #212120;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #d95926;
  --accent-wash: rgba(217, 89, 38, 0.10);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.quick-nav {
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 24px 12px;
  display: flex;
  gap: 18px;
  overflow-x: auto;
}

.quick-nav a {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.quick-nav a:hover {
  color: var(--accent);
}

section[id] {
  scroll-margin-top: 76px;
}

h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 600;
}

.topbar-brand {
  display: flex;
  align-items: center;
}

.site-logo {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  object-fit: cover;
  flex: none;
  transition: transform 0.3s ease;
}

/* przy scrollowaniu w dół: nazwa znika, logo rosnie i zostaje samo jako znaczek */
.topbar-brand h1 {
  max-width: 340px;
  margin-left: 12px;
  opacity: 1;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.3s ease, margin-left 0.3s ease, opacity 0.2s ease;
}

body.scrolled .site-logo {
  transform: scale(1.25);
}

body.scrolled .topbar-brand h1 {
  max-width: 0;
  margin-left: 0;
  opacity: 0;
}

.accent {
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.discord-invite-btn {
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 6px;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.discord-invite-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.discord-invite-btn:active {
  transform: scale(0.96);
}

.admin-toggle-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.admin-toggle-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(25deg);
}

.admin-toggle-btn:active {
  transform: rotate(25deg) scale(0.92);
}

.guild-select-wrap {
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.guild-single {
  color: var(--text-secondary);
  font-size: 14px;
}

.guild-single .accent {
  font-weight: 600;
}

select, input.search-input {
  background: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  font-family: inherit;
}

main {
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.overview-row {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: stretch;
}

.stat-stack {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.chart-panel {
  min-width: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}

.dashboard-main, .dashboard-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(217, 89, 38, 0.55);
  animation: live-pulse 2.2s ease-out infinite;
  flex: none;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(217, 89, 38, 0.55);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(217, 89, 38, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(217, 89, 38, 0);
  }
}

.stat-value {
  font-size: 32px;
  font-weight: 600;
  margin-top: 4px;
}

.stat-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.panel h2 {
  font-size: 16px;
  margin: 0 0 16px;
  font-weight: 600;
}

.chart-wrap {
  position: relative;
  height: 260px;
}

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  padding: 12px 0;
}

.hidden {
  display: none;
}

.news-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.news-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  gap: 12px;
  padding: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.news-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.news-card img {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
  flex: none;
}

.news-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.news-card-title {
  font-weight: 600;
  font-size: 14px;
}

.news-card-summary {
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.news-card-date {
  color: var(--text-muted);
  font-size: 11px;
}

.news-card-link {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}

.news-card-link:hover {
  text-decoration: underline;
}

.tournament-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  margin: 0 -8px;
  border-bottom: 1px solid var(--gridline);
  border-radius: 6px;
  gap: 12px;
  transition: background 0.15s ease, transform 0.15s ease;
}

.tournament-row:hover {
  background: var(--surface-raised);
  transform: translateX(2px);
}

.tournament-row:last-child {
  border-bottom: none;
}

.tournament-name {
  font-weight: 600;
}

.tournament-date {
  color: var(--text-secondary);
  font-size: 13px;
}

.badge {
  background: var(--accent-wash);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.search-input {
  width: 100%;
  margin-bottom: 14px;
}

.weapon-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.category-pill {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.category-pill:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.category-pill:active {
  transform: scale(0.95);
}

.category-pill.active {
  background: var(--accent-wash);
  border-color: var(--accent);
  color: var(--accent);
}

.weapons-layout {
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: 16px;
  align-items: start;
}

.weapons-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--gridline);
  border-radius: 8px;
}

.weapons-list li {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gridline);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.15s ease, transform 0.15s ease;
}

.weapons-list li .weapon-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.weapons-list li .weapon-row-main span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weapon-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: var(--accent-wash);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.weapon-icon.size-sm {
  width: 28px;
  height: 28px;
  font-size: 10px;
}

.weapon-icon.size-lg {
  width: 56px;
  height: 56px;
  font-size: 15px;
}

.weapons-list li:last-child {
  border-bottom: none;
}

.weapons-list li:hover {
  background: var(--surface-raised);
  transform: translateX(2px);
}

.weapons-list li.active {
  background: var(--surface-raised);
}

.weapons-list .weapon-cat {
  color: var(--text-muted);
  font-size: 12px;
}

.weapon-detail {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  min-height: 160px;
}

.fade {
  transition: opacity 0.15s ease;
}

.fade.fading {
  opacity: 0;
}

.weapon-detail.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.weapon-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.weapon-detail h3 {
  margin: 0;
  font-size: 18px;
}

.weapon-detail .weapon-flavor {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
}

.weapon-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  font-size: 13px;
}

.weapon-fields dt {
  color: var(--text-muted);
  margin: 0;
}

.weapon-fields dd {
  margin: 2px 0 0;
  color: var(--text-primary);
}

.weapon-attachments {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--gridline);
}

.weapon-attachments h4 {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.attachment-group {
  margin-bottom: 10px;
}

.attachment-group-title {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-weight: 600;
}

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attachment-chip {
  background: var(--surface);
  border: 1px solid var(--gridline);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.roll-loadout-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 14px;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.roll-loadout-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.roll-loadout-btn:active {
  transform: scale(0.96);
}

.roll-loadout-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.dice-emoji {
  display: inline-block;
}

.dice-emoji.spinning {
  animation: dice-spin 0.6s linear infinite;
}

@keyframes dice-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.tournament-countdown {
  background: var(--accent-wash);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.tournament-countdown .tc-label {
  color: var(--text-secondary);
  font-size: 12px;
}

.tournament-countdown .tc-name {
  font-weight: 600;
  font-size: 14px;
  margin: 2px 0 4px;
}

.tournament-countdown .tc-clock {
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: inline-block;
  animation: tc-pulse 2.2s ease-in-out infinite;
}

.tournament-countdown .tc-clock.urgent {
  color: #e66767;
  animation: tc-pulse-urgent 0.7s ease-in-out infinite;
}

@keyframes tc-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@keyframes tc-pulse-urgent {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.04);
  }
}

/* --- panel administratora --- */

.admin-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.admin-panel.open {
  opacity: 1;
  pointer-events: auto;
}

.admin-panel-inner {
  width: 340px;
  max-width: 100%;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.admin-panel.open .admin-panel-inner {
  transform: translateX(0);
}

.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.admin-panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.admin-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.1s ease;
}

.admin-close-btn:hover {
  color: var(--text-primary);
  transform: rotate(90deg);
}

.admin-field {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 14px;
}

.admin-field input {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}

.admin-save-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.admin-save-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.admin-save-btn:active {
  transform: scale(0.96);
}

.admin-status {
  font-size: 13px;
  margin-top: 10px;
  color: var(--text-muted);
}

.admin-status.ok {
  color: #0ca30c;
}

.admin-status.error {
  color: #e66767;
}

.admin-insecure-warning {
  background: rgba(230, 103, 103, 0.12);
  border: 1px solid #e66767;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.admin-insecure-warning a {
  color: #e66767;
  font-weight: 600;
}

/* --- szkielet ładowania (shimmer) --- */

.skeleton-row,
.skeleton-news-card {
  position: relative;
  overflow: hidden;
  background: var(--surface-raised);
}

.skeleton-row::after,
.skeleton-news-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-row {
  height: 41px;
  border-bottom: 1px solid var(--gridline);
}

.skeleton-news-card {
  height: 92px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* --- sekcje pojawiające się przy scrollowaniu --- */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- toasty --- */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.ok {
  border-left-color: #0ca30c;
}

.toast.error {
  border-left-color: #e66767;
}

@media (max-width: 1100px) {
  .overview-row {
    grid-template-columns: 1fr;
  }

  .stat-stack {
    flex-direction: row;
    justify-content: flex-start;
  }

  .stat-stack .stat-tile {
    flex: 1;
    min-width: 0;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-side {
    order: -1;
  }
}

@media (max-width: 640px) {
  .weapons-layout {
    grid-template-columns: 1fr;
  }

  .stat-stack {
    flex-direction: column;
  }
}
