:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d7dde7;
  --accent: #d62828;
  --accent-2: #1d4e89;
  --accent-3: #b08968;
  --warn: #92400e;
  --shadow: 0 12px 30px rgba(17, 24, 39, 0.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(214, 40, 40, 0.08), transparent 28%),
    radial-gradient(circle at left bottom, rgba(29, 78, 137, 0.08), transparent 24%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
}
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
}
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(214, 40, 40, 0.96), rgba(29, 78, 137, 0.96));
  color: white;
  border-radius: 24px;
  padding: 26px;
  margin: 24px 24px 0;
  box-shadow: var(--shadow);
}
@media (min-width: 1028px) {
  .hero { margin: 24px auto 0; max-width: 980px; }
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto -60px -90px auto;
  width: 260px;
  height: 260px;
  background: url("../esrca_logo.png") center/contain no-repeat;
  opacity: 0.12;
  pointer-events: none;
}
.hero-topbar {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 14px;
}
.hero-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}
.hero-nav-link:hover { background: rgba(255, 255, 255, 0.24); }
.hero-nav-link.is-current { background: rgba(255, 255, 255, 0.32); cursor: default; }
.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 20px;
}
.hero-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 20px;
  padding: 8px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.14);
}
.hero-badge {
  display: inline-block;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hero h1 { margin: 0; font-size: 28px; }

@media (max-width: 560px) {
  .hero { margin: 12px 12px 0; padding: 18px; }
  .hero-topbar { justify-content: center; text-align: center; }
  .hero-inner { flex-direction: column; text-align: center; }
  .hero-logo { width: 72px; height: 72px; }
  .hero h1 { font-size: 22px; }
  .wrap { padding: 16px; }
}
.hint { color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--accent-2); text-decoration: none; font-weight: 700; }
.back-link:hover { text-decoration: underline; }
.print-header { display: none; }
.print-table { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2 {
  margin-top: 0;
  font-size: 20px;
  color: var(--accent-2);
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(29, 78, 137, 0.08);
}

.tournament-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.tournament-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tournament-card:hover { transform: translateY(-2px); }
.tournament-card.is-past { opacity: 0.7; }
.tournament-card strong { display: block; color: var(--accent-2); font-size: 17px; margin-bottom: 4px; }
.tournament-card span { color: var(--muted); font-size: 14px; }

details.past-details { margin-top: 28px; }
details.past-details summary { cursor: pointer; font-weight: 700; color: var(--muted); }

.class-card { margin-bottom: 18px; overflow: hidden; padding: 0; }
.class-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(29, 78, 137, 0.06);
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.class-card-head h2 { margin: 0; padding: 0; border: none; color: var(--accent-2); font-size: 18px; }
.btn-print {
  background: white;
  color: var(--accent-2);
  border: 1px solid rgba(29, 78, 137, 0.35);
  font-size: 13px;
  padding: 8px 12px;
}
.btn-print:hover { background: rgba(29, 78, 137, 0.06); }

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.group-column { border-bottom: 1px solid var(--line); }
.group-column:nth-last-child(-n+1) { border-bottom: none; }
@media (min-width: 620px) {
  .group-column { border-bottom: none; border-right: 1px solid var(--line); }
  .group-column:last-child { border-right: none; }
}
.group-column-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: rgba(29, 78, 137, 0.03);
  border-bottom: 1px solid var(--line);
}
.group-name { font-weight: 700; color: var(--text); }
.fill-count { font-size: 12px; color: var(--accent-2); font-weight: 700; white-space: nowrap; }
.fill-count.is-full { color: var(--accent); }
.slot-list { list-style: none; margin: 0; padding: 0; }
.slot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}
.slot-row:last-child { border-bottom: none; }
.slot-name-badge {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 999px;
  background: #f1f3f6;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}
.slot-name-badge-empty {
  background: none;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-style: italic;
}
.signup-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
}
.signup-form input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  flex: 1;
  min-width: 100px;
}

button, .btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--accent-2); color: white; }
.btn-primary:hover { background: #163f6e; }
.btn-danger-outline { background: white; color: var(--accent); border: 1px solid rgba(214, 40, 40, 0.4); }
.btn-danger-outline:hover { background: rgba(214, 40, 40, 0.06); }

.note {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: var(--warn);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  margin: 12px 0;
}
.error-text { color: var(--accent); font-size: 13px; margin-top: 4px; }

.site-footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 24px 40px;
  text-align: center;
  font-size: 13px;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* Admin */
.admin-login { max-width: 380px; margin: 40px auto 0; }
.admin-login input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 15px;
  margin-bottom: 12px;
}
.admin-section { margin-bottom: 28px; }
.admin-section h2 { color: var(--accent-2); }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form input[type="text"],
.inline-form input[type="date"],
.inline-form input[type="time"],
.inline-form input[type="number"],
.inline-form select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
}
.inline-form input[type="number"] { width: 60px; }
.small-label { font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.link-danger { color: var(--accent); background: none; border: none; padding: 0; font-weight: 700; cursor: pointer; text-decoration: underline; font-size: 13px; }
.link-plain { color: var(--accent-2); background: none; border: none; padding: 0; font-weight: 700; cursor: pointer; text-decoration: underline; font-size: 13px; }

.tournament-admin-card {
  border: 2px solid var(--accent-3);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 22px;
  background: #fdfcfb;
  box-shadow: var(--shadow);
}
.tournament-admin-card .head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 8px; }
.tournament-admin-card .head strong { color: var(--text); font-size: 18px; }
.tournament-admin-card .head .meta { color: var(--muted); font-size: 13px; }

.edit-details { margin-top: 10px; }
.edit-details summary { cursor: pointer; font-size: 13px; color: var(--accent-2); font-weight: 700; }

.section-label {
  margin: 18px 0 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.section-label-sub { margin: 10px 0 6px; }

.field-tag {
  display: inline-block;
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--accent-2);
  color: white;
}
.field-tag-sub { background: var(--accent-3); }
.field-tag-new { background: var(--accent); }

.class-admin-block {
  margin: 0 0 0 10px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent-2);
  border-radius: 0 14px 14px 0;
  background: rgba(29, 78, 137, 0.05);
}
.class-admin-block + .class-admin-block { margin-top: 12px; }
.class-admin-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.class-name-input { font-weight: 700; color: var(--text); min-width: 130px; }
.group-admin-list { margin: 0 0 0 18px; padding-left: 12px; border-left: 2px dashed var(--accent-3); display: flex; flex-direction: column; gap: 6px; }
.group-admin-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.group-add-row { background: transparent; border: 1px dashed var(--line); }
.group-name-input { min-width: 140px; }
.add-class-form {
  margin: 22px 0 0 0;
  padding: 14px;
  border: 1px dashed var(--accent);
  border-radius: 14px;
  background: rgba(214, 40, 40, 0.03);
}
.class-chip {
  background: white;
  border: 1px solid rgba(29, 78, 137, 0.4);
  color: var(--accent-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* Statistik */
.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
}
.table-scroll { overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  color: var(--accent-2);
  white-space: nowrap;
}
.stats-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.stats-table tbody tr:hover { background: rgba(29, 78, 137, 0.04); }

/* Druckansicht */
@media print {
  @page { margin: 1.2cm; }
  .no-print, .no-print-block, form, .hero, .pd-print-hide { display: none !important; }
  body { background: white; }
  .wrap { max-width: none; padding: 0; margin: 0; }
  .print-header { display: block; margin-bottom: 14px; }
  .print-header h1 { font-size: 14px; margin: 0 0 4px; color: var(--text); }
  .print-header h2 { font-size: 19px; margin: 0 0 4px; color: var(--text); }
  .print-header p { margin: 0; color: var(--text); }
  .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }

  .print-table {
    display: table;
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }
  .print-table th, .print-table td {
    border: 1px solid #999;
    padding: 5px 7px;
    text-align: left;
    vertical-align: top;
  }
  .print-table th { background: #eee; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
  .print-table tr.pd-print-hide { display: none; }
  .print-count { font-weight: normal; color: #555; font-size: 11px; }
  .print-blank { color: #999; }
}
