* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Source Sans 3', system-ui, sans-serif;
  color: #1c1917;
  background-color: #f5f0e8;
}

.font-display {
  font-family: 'DM Serif Display', Georgia, serif;
}

/* Layout */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
}

.app-main--fade {
  animation: pageFadeIn 0.35s ease-out;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.site-header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #ebe4d8;
  position: sticky;
  top: 0;
  z-index: 40;
}

.site-header__inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: #1b4332;
  flex-shrink: 0;
}

.site-brand img {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  flex-shrink: 0;
}

.site-brand__logo,
.site-footer__logo {
  object-fit: contain;
}

.site-footer__logo {
  width: 1.75rem;
  height: 1.75rem;
}

.site-brand__text {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.125rem;
  line-height: 1.2;
}

.site-brand__text span {
  display: block;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #78716c;
}

.nav-desktop {
  display: none;
  align-items: center;
  gap: 0.25rem;
}

@media (min-width: 1024px) {
  .nav-desktop {
    display: flex;
  }
  .nav-mobile-toggle {
    display: none !important;
  }
}

.nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #57534e;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: #2d6a4f;
  background: #f5f0e8;
}

.nav-link--active {
  color: #1b4332;
  background: #ebe4d8;
  font-weight: 600;
}

.nav-auth {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-mobile-sheet {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
}

.nav-mobile-sheet.is-open {
  display: block;
}

.nav-mobile-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
  animation: fadeIn 0.2s ease;
}

.nav-mobile-sheet__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(20rem, 88vw);
  height: 100%;
  background: white;
  padding: 1.25rem;
  box-shadow: -8px 0 32px rgba(28, 25, 23, 0.12);
  animation: slideIn 0.25s ease;
  overflow-y: auto;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.nav-mobile-sheet .nav-link {
  display: block;
  margin-bottom: 0.25rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid #ebe4d8;
  background: white;
  margin-top: auto;
}

.site-footer__inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
  color: #78716c;
}

.site-footer__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.7;
}

.site-footer__brand img {
  width: 1.5rem;
  height: 1.5rem;
}

/* Components */
.card {
  background: white;
  border: 1px solid #ebe4d8;
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.06), 0 8px 24px rgba(28, 25, 23, 0.04);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f5f0e8;
}

.card-body {
  padding: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: #2d6a4f;
  color: white;
}

.btn-primary:hover {
  background: #1b4332;
}

.btn-secondary {
  background: #1c1917;
  color: white;
}

.btn-secondary:hover {
  background: #292524;
}

.btn-outline {
  background: white;
  color: #2d6a4f;
  border: 1px solid #d6d3d1;
}

.btn-outline:hover {
  background: #f5f0e8;
  border-color: #2d6a4f;
}

.btn-danger {
  background: #b91c1c;
  color: white;
}

.btn-danger:hover {
  background: #991b1b;
}

.btn-amber {
  background: #b45309;
  color: white;
}

.btn-amber:hover {
  background: #92400e;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge--group {
  background: #d8f3dc;
  color: #1b4332;
}

.badge--playoff {
  background: #dbeafe;
  color: #1e40af;
}

.badge--semifinal {
  background: #e0e7ff;
  color: #3730a3;
}

.badge--final {
  background: #fef3c7;
  color: #92400e;
}

.badge--registration {
  background: #d8f3dc;
  color: #1b4332;
}

.badge--locked {
  background: #fef3c7;
  color: #92400e;
}

.badge--countdown {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.page-hero {
  position: relative;
  border-radius: 1.25rem;
  overflow: hidden;
  background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 50%, #40916c 100%);
  color: white;
  padding: 2.5rem 1.5rem;
}

@media (min-width: 640px) {
  .page-hero {
    padding: 3.5rem 2.5rem;
  }
}

.page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 85% 20%, rgba(201, 162, 39, 0.25) 0%, transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(0, 0, 0, 0.15) 0%, transparent 50%);
  pointer-events: none;
}

.page-hero__content {
  position: relative;
  z-index: 1;
}

.site-hero__logo {
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}

.hero-tournament-date {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.page-hero--image {
  background-size: cover;
  background-position: center;
}

.page-hero--image::before {
  background:
    linear-gradient(135deg, rgba(27, 67, 50, 0.92) 0%, rgba(45, 106, 79, 0.82) 50%, rgba(64, 145, 108, 0.75) 100%),
    radial-gradient(circle at 85% 20%, rgba(201, 162, 39, 0.2) 0%, transparent 45%);
}

.group-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: #1b4332;
  color: white;
}

.group-card__court {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.5rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.15);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.group-card__progress {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
}

.tournament-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.lightbox {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.lightbox.is-open {
  opacity: 1;
}

.lightbox img {
  transition: transform 0.25s ease;
}

.lightbox.is-open img {
  transform: scale(1);
}

.section-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.5rem;
  color: #1b4332;
  margin-bottom: 1rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #78716c;
}

.empty-state__icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  opacity: 0.4;
}

.feature-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .feature-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.feature-card {
  background: white;
  border: 1px solid #ebe4d8;
  border-radius: 1rem;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.2s;
}

.feature-card:hover {
  box-shadow: 0 4px 12px rgba(28, 25, 23, 0.08);
  transform: translateY(-2px);
}

.feature-card__icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  background: #d8f3dc;
  color: #2d6a4f;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}

/* Tables */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  font-size: 0.875rem;
  border-collapse: collapse;
}

.data-table thead {
  background: #f5f0e8;
  text-align: left;
}

.data-table th {
  padding: 0.625rem 0.75rem;
  font-weight: 600;
  color: #57534e;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 0.625rem 0.75rem;
  border-top: 1px solid #f5f0e8;
}

.data-table tbody tr:hover {
  background: #fafaf9;
}

.data-table .row-gold td {
  background: #fffbeb;
}

.data-table .row-silver td {
  background: #f8fafc;
}

.data-table .row-bronze td {
  background: #fff7ed;
}

.data-table .sticky-col {
  position: sticky;
  left: 0;
  background: inherit;
  z-index: 1;
}

/* Countdown */
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  max-width: 20rem;
  margin: 1rem auto 0;
}

.countdown-unit {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.75rem;
  padding: 0.5rem;
  text-align: center;
}

.countdown-unit__value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.countdown-unit__label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
}

/* Match scoreboard */
.match-scoreboard {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f5f0e8;
}

.match-scoreboard:last-child {
  border-bottom: none;
}

.match-scoreboard__label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a8a29e;
}

.match-scoreboard__row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.match-scoreboard__team {
  flex: 1;
  min-width: 0;
}

.match-scoreboard__score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #1b4332;
  min-width: 1.5rem;
  text-align: center;
}

.match-scoreboard--played {
  border-left: 3px solid #2d6a4f;
  padding-left: 0.75rem;
  margin-left: -0.75rem;
}

/* Bracket */
.bracket-flow {
  display: flex;
  gap: 1.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.bracket-round {
  min-width: 14rem;
  flex-shrink: 0;
}

.bracket-round__title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #78716c;
  margin-bottom: 0.75rem;
}

/* Historik year cards */
.year-card {
  border: 1px solid #ebe4d8;
  border-radius: 1rem;
  overflow: hidden;
  background: white;
  transition: box-shadow 0.2s;
}

.year-card:hover {
  box-shadow: 0 4px 12px rgba(28, 25, 23, 0.06);
}

.year-card__header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
}

.year-card__header[aria-expanded="true"] {
  background: #f5f0e8;
}

.year-card__year {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 2rem;
  color: #2d6a4f;
  line-height: 1;
  min-width: 4rem;
}

.year-card__chevron {
  margin-left: auto;
  transition: transform 0.25s ease;
  color: #a8a29e;
  flex-shrink: 0;
}

.year-card__header[aria-expanded="true"] .year-card__chevron {
  transform: rotate(90deg);
}

.year-card__stats {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.year-card__stats.is-open {
  max-height: 4000px;
}

/* Gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.gallery-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 0.75rem;
  overflow: hidden;
  cursor: pointer;
  background: #ebe4d8;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-thumb:hover img {
  transform: scale(1.05);
}

/* Admin */
.danger-zone {
  border: 2px solid #fecaca;
  border-radius: 1rem;
  background: linear-gradient(to bottom, #fef2f2, white);
  padding: 1.25rem 1.5rem;
}

.danger-zone__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: #991b1b;
  margin-bottom: 0.75rem;
}

.accordion-section {
  border: 1px solid #ebe4d8;
  border-radius: 0.75rem;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: #f5f0e8;
  border: none;
  font-weight: 600;
  font-size: 0.875rem;
  color: #1b4332;
  cursor: pointer;
  text-align: left;
}

.accordion-panel {
  display: none;
  padding: 1rem;
  background: white;
}

.accordion-panel.is-open {
  display: block;
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, #f5f0e8 25%, #ebe4d8 50%, #f5f0e8 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 0.375rem;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-row {
  height: 2.5rem;
  margin-bottom: 0.5rem;
}

/* Form inputs */
.input {
  width: 100%;
  border: 1px solid #d6d3d1;
  border-radius: 0.625rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: #2d6a4f;
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.15);
}

.alert {
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.flatpickr-calendar {
  font-family: inherit;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: #2d6a4f;
  border-color: #2d6a4f;
}

.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
  background: #1b4332;
  border-color: #1b4332;
}

.flatpickr-time input:hover,
.flatpickr-time input:focus {
  background: #d8f3dc;
}
