:root {
  --ink: #1a2418;
  --muted: #5a6b55;
  --paper: #f3efe4;
  --paper-2: #e8e2d2;
  --forest: #2f5d3a;
  --forest-deep: #1e3d28;
  --clay: #c45c26;
  --clay-soft: #e8a078;
  --club: #1f6b8a;
  --club-bg: #d9eef5;
  --danger: #9b2c2c;
  --warn: #8a5a12;
  --ok: #1f6b3a;
  --line: rgba(26, 36, 24, 0.12);
  --shadow: 0 18px 50px rgba(30, 45, 28, 0.12);
  --radius: 14px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(47, 93, 58, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(196, 92, 38, 0.12), transparent 50%),
    linear-gradient(180deg, #f7f3ea 0%, var(--paper) 40%, #ebe4d4 100%);
  background-attachment: fixed;
}

a {
  color: var(--forest);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--clay);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  background: rgba(243, 239, 228, 0.88);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--forest-deep);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.landing-page .main {
  max-width: none;
  padding: 0;
}

.landing {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 2rem 1.25rem;
}

.landing-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(30, 61, 40, 0.92), rgba(47, 93, 58, 0.75)),
    repeating-linear-gradient(
      -18deg,
      transparent 0 18px,
      rgba(255, 255, 255, 0.03) 18px 19px
    );
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.landing-panel {
  position: relative;
  z-index: 1;
  max-width: 34rem;
  width: 100%;
  color: #f7f3ea;
  animation: rise 0.7s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.brand-mark {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 700;
  margin: 0 0 0.75rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.landing h1 {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  margin: 0 0 0.75rem;
  line-height: 1.35;
}

.landing .lede {
  color: rgba(247, 243, 234, 0.82);
  margin-bottom: 1.75rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.landing .btn-primary {
  background: var(--clay);
  border-color: var(--clay);
  color: #fff;
}

.landing .btn-secondary {
  background: transparent;
  border-color: rgba(247, 243, 234, 0.55);
  color: #f7f3ea;
}

.landing .btn-secondary:hover {
  background: rgba(247, 243, 234, 0.12);
  color: #fff;
}

h1, h2 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 0.5rem;
}

.lede {
  color: var(--muted);
  margin: 0;
  max-width: 40rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}

.btn-primary:hover {
  background: var(--forest-deep);
  color: #fff;
}

.btn-secondary {
  background: var(--paper-2);
  border-color: var(--line);
  color: var(--ink);
}

.btn-accent {
  background: var(--clay);
  border-color: var(--clay);
  color: #fff;
}

.btn-accent:hover {
  background: #a84b1d;
  color: #fff;
}

.btn-accent-outline {
  background: transparent;
  border-color: var(--club);
  color: var(--club);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn-warn {
  background: #f3e2c4;
  border-color: #e0c48a;
  color: var(--warn);
}

.btn-disabled {
  background: #d9d4c8;
  color: #888;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-block {
  width: 100%;
}

.flash-stack {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.flash-success { border-color: #9dcea8; background: #e8f6eb; color: var(--ok); }
.flash-error { border-color: #e2a8a8; background: #fbeeee; color: var(--danger); }
.flash-warning { border-color: #e0c48a; background: #fff6e5; color: var(--warn); }
.flash-info { border-color: #a8c9e2; background: #eef5fb; color: #1f4f6b; }

.auth-card,
.panel {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.auth-card {
  max-width: 420px;
  margin: 2rem auto;
  animation: rise 0.45s ease both;
}

.auth-card form,
.panel form {
  display: grid;
  gap: 0.85rem;
}

.auth-links {
  margin-top: 1rem;
  text-align: center;
  color: var(--muted);
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.input,
.input-file {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #fff;
  font: inherit;
  color: var(--ink);
}

.input:focus {
  outline: 2px solid rgba(47, 93, 58, 0.35);
  border-color: var(--forest);
}

.textarea {
  resize: vertical;
  min-height: 100px;
}

.input-sm {
  width: 4.5rem;
  display: inline-block;
  padding: 0.35rem 0.5rem;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.panel.narrow {
  max-width: 480px;
}

.race-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.9rem;
}

.race-card {
  display: grid;
  gap: 1rem;
  padding: 1rem 1.15rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(30, 45, 28, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  animation: rise 0.4s ease both;
}

.race-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.race-card.is-club {
  background: linear-gradient(90deg, var(--club-bg), rgba(255, 255, 255, 0.85));
  border-color: rgba(31, 107, 138, 0.35);
}

.race-card.is-closed {
  opacity: 0.82;
}

.race-card.is-past {
  background: rgba(220, 220, 218, 0.72);
  border-color: rgba(120, 120, 118, 0.22);
  box-shadow: none;
  opacity: 0.78;
}

.race-card.is-past .race-date {
  background: #8a8f88;
}

.race-card.is-past.is-club {
  background: linear-gradient(90deg, #d5dfe3, rgba(220, 220, 218, 0.85));
}

.race-card.is-past .race-name-link {
  color: #6a6e68 !important;
}

.race-card.is-past .meta,
.race-card.is-past .details,
.race-card.is-past .entry-count {
  color: #7a7e78;
}

#elso-kovetkezo {
  scroll-margin-top: 5.5rem;
}

.race-main {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.race-date {
  flex: 0 0 auto;
  min-width: 4.2rem;
  text-align: center;
  padding: 0.55rem 0.4rem;
  border-radius: 12px;
  background: var(--forest);
  color: #fff;
  line-height: 1.1;
}

.race-card.is-club .race-date {
  background: var(--club);
}

.race-date .day {
  display: block;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
}

.race-date .month,
.race-date .year {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

.race-info h2 {
  font-size: 1.15rem;
  margin-bottom: 0.35rem;
}

.race-info h2 a {
  color: inherit;
  text-decoration: none;
}

.race-info h2 a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.race-name-link {
  text-decoration: none;
}

.filter-banner {
  margin: -0.5rem 0 1rem;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  background: var(--club-bg);
  color: var(--club);
  font-size: 0.95rem;
}

.deadline {
  margin: 0.45rem 0 0;
  font-weight: 600;
  line-height: 1.3;
}

.deadline-extra {
  font-weight: 800;
}

.deadline-ok {
  font-size: 0.9rem;
  color: var(--muted);
}

.deadline-near {
  font-size: 0.98rem;
  color: #b45309;
}

.deadline-soon {
  font-size: 1.08rem;
  color: #c2410c;
  font-weight: 700;
}

.deadline-critical {
  font-size: 1.22rem;
  color: #b91c1c;
  font-weight: 800;
  animation: deadline-pulse 1.6s ease-in-out infinite;
}

.deadline-overdue {
  font-size: 1.28rem;
  color: #7f1d1d;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@keyframes deadline-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

.race-card.is-past .deadline {
  display: none;
}

.race-date .day-range {
  font-size: 1.05rem;
}

.hint {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.day-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  width: 100%;
}

.panel-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.25rem 0;
}

.panel h3 {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  color: var(--muted);
  margin: 0;
  font-size: 0.92rem;
}

.details {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge.club {
  background: var(--club);
  color: #fff;
}

.badge.closed {
  background: #efe0e0;
  color: var(--danger);
}

.race-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.race-actions form {
  display: inline;
  margin: 0;
}

.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
}

.runner-toolbar {
  margin-bottom: 0.75rem;
}

.runner-select-list {
  list-style: none;
  margin: 0 0 5rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.runner-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  align-items: start;
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.runner-row.already {
  opacity: 0.55;
}

.runner-check {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.65rem;
  row-gap: 0.15rem;
  align-items: center;
  font-weight: 500;
}

.runner-check input {
  grid-row: 1 / span 2;
  width: 1.15rem;
  height: 1.15rem;
}

.runner-name {
  font-weight: 700;
}

.runner-meta {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.88rem;
}

.icon-edit {
  color: var(--muted);
  text-decoration: none;
  font-size: 1.1rem;
  padding: 0.2rem 0.4rem;
  border-radius: 8px;
}

.icon-edit:hover {
  background: var(--paper-2);
  color: var(--clay);
}

.runner-extras {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  padding-top: 0.35rem;
  border-top: 1px dashed var(--line);
  margin-top: 0.25rem;
}

.runner-extras label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 0.85rem 0;
  background: linear-gradient(transparent, var(--paper) 30%);
  display: flex;
  justify-content: flex-end;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  background: rgba(47, 93, 58, 0.08);
  font-weight: 700;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.dev-reset {
  margin-top: 1rem;
  padding: 0.85rem;
  background: #fff6e5;
  border-radius: 10px;
  word-break: break-all;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .race-main {
    flex-direction: column;
  }

  .race-date {
    display: inline-flex;
    gap: 0.35rem;
    align-items: baseline;
    min-width: 0;
    padding: 0.4rem 0.7rem;
  }

  .race-date .day,
  .race-date .month,
  .race-date .year {
    display: inline;
  }
}
