:root {
  --bg: #f4f5f7;
  --bg-strong: #ffffff;
  --ink: #111827;
  --ink-soft: #57606a;
  --line: rgba(17, 24, 39, 0.08);
  --line-strong: rgba(17, 24, 39, 0.14);
  --brand: #12584f;
  --brand-soft: #e7f3ee;
  --accent: #b75a36;
  --accent-soft: #f6e8df;
  --shadow: 0 20px 40px rgba(17, 24, 39, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --max-width: 760px;
  --transition: 180ms ease;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f8f9fb 0%, #eef1f5 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(var(--max-width), 100%);
  margin: 0 auto;
  padding: 18px 16px 96px;
}

body[data-page="tournament"] .page-shell {
  width: min(980px, 100%);
}

.hero-card,
.view-panel,
.modal-card {
  border: none;
  background: var(--bg-strong);
  box-shadow: var(--shadow);
}

.hero-card h1,
.page-title,
.section-heading h2,
.section-heading h3,
.modal-header h3 {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  letter-spacing: -0.02em;
}

.page-title {
  font-size: clamp(1.55rem, 4vw, 2.4rem);
  line-height: 1.05;
}

.view-stack {
  display: grid;
  gap: 18px;
}

.tournament-stage-panel {
  display: grid;
  gap: 12px;
  width: 100%;
}

.view-panel {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 20px;
  border-radius: var(--radius-xl);
  animation: rise-in 220ms ease;
  box-sizing: border-box;
}

.simple-panel {
  padding: 14px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-heading.compact {
  margin-bottom: 14px;
}

.section-action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.tournament-stage-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  margin-bottom: 8px;
}

.tournament-stage-heading .page-title {
  padding-top: 0.15rem;
}

.tournament-stage-heading .section-action-row {
  align-items: flex-start;
}

.primary-button,
.secondary-button,
.icon-button,
.archive-button,
.history-button,
.nav-link {
  border: 1px solid transparent;
  border-radius: 999px;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background-color var(--transition);
}

.primary-button,
.secondary-button,
.icon-button,
.archive-button,
.nav-link {
  padding: 12px 16px;
  font-weight: 700;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--brand), #1a7f63);
  box-shadow: 0 18px 38px rgba(18, 88, 79, 0.18);
}

.secondary-button,
.archive-button,
.icon-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  border-color: var(--line);
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.archive-button:hover,
.history-button:hover,
.nav-button:hover,
.nav-link:hover {
  transform: translateY(-1px);
}

.info-strip,
.signup-card,
.archive-card,
.history-button,
.ranking-card,
.bracket-match {
  border: none;
  background: var(--bg-strong);
  border-radius: var(--radius-lg);
}

.info-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0;
  background: transparent;
}

.info-pill {
  min-width: fit-content;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(18, 88, 79, 0.08);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.info-label {
  display: none;
}

.info-value {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
}

.bracket-shell {
  overflow-x: auto;
  margin-bottom: 18px;
  padding-bottom: 6px;
}

.bracket-grid {
  display: grid;
  grid-auto-flow: column;
  /* kompaktere Default-Spaltenbreite, skaliert bei Bedarf */
  grid-auto-columns: minmax(220px, 220px);
  gap: 14px;
  align-items: start;
}

.round-column {
  display: grid;
  gap: 12px;
  min-width: 220px;
  /* Verhindert Überlappungen und sorgt für konsistente Spaltenhöhe */
  align-content: start;
}

/* Stacking context: verhindert, dass Karten aus einer Spalte über die Nachbarspalte gelegt werden */
.round-column {
  isolation: isolate;
  position: relative;
  /* Sicherstellen, dass Spalten nicht schrumpfen und ihre eigene Fläche behalten */
  min-width: 220px;
  box-sizing: border-box;
  overflow: visible;
}

.round-label {
  position: sticky;
  top: 8px;
  z-index: 2;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  border: 1px solid rgba(17, 24, 39, 0.06);
}

.bracket-match {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 12px;
  min-height: 120px;
  border-radius: 18px;
  box-shadow: 0 12px 22px rgba(17, 24, 39, 0.06);
  cursor: pointer;
}

/* Matches müssen sich an die Spaltenbreite halten */
.bracket-match {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  z-index: 0;
}

/* Verhindert, dass Flex-Kinder die Spaltenbreite sprengen */
.match-team {
  min-width: 0;
}

.match-team-label {
  min-width: 0;
  overflow: hidden;
}

.match-team-label strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* sicherstellen, dass einzelne Karten nicht aus ihrem Kontext herausstapeln */
.bracket-match {
  z-index: 0;
}

.bracket-match:focus-visible {
  outline: 2px solid rgba(18, 88, 79, 0.35);
  outline-offset: 4px;
}

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

.match-main {
  display: grid;
  gap: 8px;
}

.match-title {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink-soft);
  text-transform: none;
  margin-bottom: 6px;
}

.match-team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(17, 24, 39, 0.06);
}

.match-team.is-empty {
  opacity: 0.82;
  background: rgba(243, 244, 246, 0.72);
}

.match-team strong {
  font-size: 0.82rem;
  /* ca. 10–12px */
  font-weight: 700;
}

.match-team-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.match-team-score {
  min-width: 0;
  width: auto;
  flex-shrink: 0;
  text-align: right;
  font-weight: 800;
  font-size: 0.85rem;
  /* ca. 9–10px */
  color: var(--ink-soft);
}

.match-team-score:empty {
  width: 0;
  min-width: 0;
  padding: 0;
}

.match-team.is-winner {
  box-shadow: inset 4px 0 0 0 rgba(18, 88, 79, 0.25);
  background: linear-gradient(90deg, rgba(18, 88, 79, 0.12), #fff);
  border-color: rgba(18, 88, 79, 0.18);
}

.match-team.is-winner strong,
.match-team.is-winner .match-team-score {
  color: #12553c;
}

.match-team.is-winner strong {
  font-weight: 800;
}

.match-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.match-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(18, 88, 79, 0.1);
  color: var(--brand);
}

.match-status-chip.status-action {
  background: var(--accent-soft);
  color: #9a4028;
}

.match-status-chip.status-pending {
  background: rgba(226, 232, 240, 0.9);
  color: var(--ink-soft);
}

.match-status-chip.status-complete {
  background: rgba(18, 88, 79, 0.14);
  color: var(--brand);
}

.match-status-detail {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.empty-state {
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.54);
}

.signup-card,
.archive-card {
  padding: 14px;
}

.signup-preview,
.past-tournaments,
.history-list,
.ranking-list {
  display: grid;
  gap: 8px;
}

.signup-team-card,
.history-button,
.ranking-card {
  padding: 12px;
  background: white;
}

.signup-team-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.signup-team-card strong,
.history-title,
.ranking-name {
  display: block;
}

.signup-team-card span,
.history-meta,
.ranking-meta {
  color: var(--ink-soft);
}

.ranking-heading {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
}

.ranking-heading > :first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.ranking-mode-switch {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.18rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  flex: 0 0 auto;
  margin-left: auto;
}

.ranking-mode-button {
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
}

.ranking-mode-button.is-active {
  background: linear-gradient(135deg, var(--brand), #17875f);
  color: white;
}

.signup-page-actions {
  display: flex;
  justify-content: flex-start;
}

.past-tournaments {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.tournament-section {
  display: grid;
  gap: 1.25rem;
  margin-top: 0.85rem;
}

.tournament-phase-switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
  padding: 0.18rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 23, 42, 0.07);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.tournament-phase-button {
  border: 0;
  border-radius: 999px;
  padding: 0.48rem 0.82rem;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease,
    transform 160ms ease;
}

.tournament-phase-button:hover {
  color: var(--ink);
  transform: translateY(-1px);
}

.tournament-phase-button.is-active {
  background: linear-gradient(135deg, var(--brand), #17875f);
  color: white;
  box-shadow: 0 4px 12px rgba(18, 88, 79, 0.15);
}

.group-overview-stack {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr);
}

.group-overview-card {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.94);
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
  transition: transform 160ms ease, box-shadow 160ms ease,
    border-color 160ms ease;
}

.group-overview-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.1);
}

.group-overview-card:focus-visible {
  outline: 2px solid rgba(18, 88, 79, 0.35);
  outline-offset: 4px;
}

.group-overview-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.group-overview-header h3 {
  margin: 0;
}

.group-overview-header span {
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 700;
}

.group-section {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.92);
}

.group-table-wrap {
  overflow-x: auto;
}

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

.group-table th,
.group-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  text-align: left;
}

.group-table .is-qualified td {
  font-weight: 700;
}

.group-matches {
  display: grid;
  gap: 0.9rem;
}

.group-phase-toolbar {
  position: sticky;
  top: 12px;
  z-index: 6;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.2rem;
}

.group-tables-button {
  padding: 0.7rem 0.95rem;
  border: 1px solid rgba(18, 88, 79, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--brand);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.08);
}

.group-tables-button:hover {
  transform: translateY(-1px);
}

.group-detail-heading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.group-detail-heading h3,
.group-detail-heading p {
  margin: 0;
}

.group-detail-heading p {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.match-score-grid-compact {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.match-score-compact-field {
  gap: 0.55rem;
  padding: 0.95rem;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(18, 88, 79, 0.05), rgba(255, 255, 255, 0.98)),
    #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.match-score-compact-field input {
  background: rgba(255, 255, 255, 0.96);
}

.match-score-heading {
  display: grid;
  gap: 0.18rem;
  padding: 0.05rem 0 0.12rem;
}

.match-score-heading-main {
  display: block;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--brand);
}

.match-score-heading-players {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink-soft);
}

.match-score-elo {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.archive-button {
  text-align: left;
}

.archive-button.is-active {
  border-color: rgba(15, 106, 76, 0.34);
  background: var(--brand-soft);
}

.archive-button small {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
}

.ranking-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 84px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: white;
}

.ranking-cell {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ranking-row.is-gold {
  border-color: rgba(176, 134, 24, 0.24);
  background: linear-gradient(135deg, rgba(247, 226, 148, 0.36), rgba(255, 250, 230, 0.98));
}

.ranking-row.is-silver {
  border-color: rgba(119, 129, 145, 0.22);
  background: linear-gradient(135deg, rgba(226, 231, 238, 0.72), rgba(255, 255, 255, 0.98));
}

.ranking-row.is-bronze {
  border-color: rgba(153, 99, 56, 0.22);
  background: linear-gradient(135deg, rgba(231, 195, 165, 0.48), rgba(255, 248, 242, 0.98));
}

.ranking-position {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.ranking-player-name {
  font-size: 0.96rem;
  font-weight: 700;
}

.ranking-meta {
  font-size: 0.82rem;
}

.ranking-player-link {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
}

.ranking-player-link:hover,
.ranking-player-link:focus-visible {
  color: var(--brand);
  text-decoration: underline;
}

.player-rank-name {
  display: inline;
}

.player-rank-name-gold {
  color: #a06a00;
}

.player-rank-name-silver {
  color: #5f6c7b;
}

.player-rank-name-bronze {
  color: #9a5428;
}

.ranking-medals {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.ranking-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.42rem;
  height: 1.42rem;
  flex: 0 0 auto;
  border-radius: 999px;
  forced-color-adjust: none;
  filter: drop-shadow(0 2px 4px rgba(17, 24, 39, 0.18));
  --medal-ribbon-left: #3677a8;
  --medal-ribbon-right: #215a89;
  --medal-disc-shadow: rgba(17, 24, 39, 0.16);
  --medal-disc: #d9dfe6;
  --medal-disc-inner: #f8fbff;
  --medal-outline: #556170;
  --medal-text: #364150;
  --medal-shine: rgba(255, 255, 255, 0.28);
}

.ranking-medal-icon {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ranking-medal-ribbon-left {
  fill: var(--medal-ribbon-left);
}

.ranking-medal-ribbon-right {
  fill: var(--medal-ribbon-right);
}

.ranking-medal-disc-shadow {
  fill: var(--medal-disc-shadow);
}

.ranking-medal-disc {
  fill: var(--medal-disc);
  stroke: var(--medal-outline);
  stroke-width: 2.6;
}

.ranking-medal-disc-inner {
  fill: var(--medal-disc-inner);
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1.4;
}

.ranking-medal-shine {
  fill: var(--medal-shine);
}

.ranking-medal-value {
  fill: var(--medal-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 20px;
  font-weight: 900;
  text-anchor: middle;
}

.ranking-medal-gold {
  --medal-disc: #d39a1c;
  --medal-disc-inner: #ffd86b;
  --medal-outline: #80560a;
  --medal-text: #533700;
  --medal-shine: rgba(255, 244, 190, 0.34);
}

.ranking-medal-silver {
  --medal-disc: #9ca8b6;
  --medal-disc-inner: #e3e8ee;
  --medal-outline: #647181;
  --medal-text: #3f4a57;
  --medal-shine: rgba(255, 255, 255, 0.3);
}

.ranking-medal-bronze {
  --medal-disc: #b86834;
  --medal-disc-inner: #e5a06a;
  --medal-outline: #73381a;
  --medal-text: #4f240f;
  --medal-shine: rgba(255, 235, 219, 0.24);
}

@media (prefers-color-scheme: dark) {
  .ranking-medal {
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.46));
  }

  .ranking-medal-gold {
    --medal-disc: #e2ad2f;
    --medal-disc-inner: #ffe184;
    --medal-outline: #f5d160;
    --medal-text: #4d3200;
  }

  .ranking-medal-silver {
    --medal-disc: #a8b3bf;
    --medal-disc-inner: #eef2f6;
    --medal-outline: #d3dae2;
    --medal-text: #36404a;
  }

  .ranking-medal-bronze {
    --medal-disc: #ca7842;
    --medal-disc-inner: #efad7d;
    --medal-outline: #f1b185;
    --medal-text: #4a220f;
  }
}

.ranking-points {
  justify-self: end;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-normal);
}

.history-button {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  border-radius: var(--radius-lg);
  border-color: var(--line);
  padding: 12px 14px;
}

.history-content {
  min-width: 0;
  display: grid;
  gap: 4px;
  flex: 1;
}

.history-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
}

.history-player-elo-change {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(18, 88, 79, 0.1);
}

.history-player-elo-change.is-positive {
  color: #12553c;
  background: linear-gradient(135deg, rgba(18, 88, 79, 0.14), rgba(231, 243, 238, 0.92));
}

.history-player-elo-change.is-neutral {
  color: var(--ink-soft);
  background: rgba(20, 31, 26, 0.08);
}

.history-player-elo-change.is-negative {
  color: #8f2f2f;
  background: linear-gradient(135deg, rgba(165, 50, 50, 0.14), rgba(252, 235, 235, 0.94));
}

.history-team-name {
  min-width: 0;
  max-width: 100%;
  color: var(--ink);
}

.history-title-separator {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.history-team-name.is-winner {
  padding: 2px 8px;
  border-radius: 999px;
  color: #12553c;
  background: linear-gradient(135deg, rgba(18, 88, 79, 0.12), rgba(231, 243, 238, 0.9));
  font-weight: 700;
}

.history-score {
  flex-shrink: 0;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}

.history-search-field {
  margin-bottom: 14px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: min(760px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 245, 0.92);
  box-shadow: var(--shadow);
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  text-decoration: none;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.nav-button.is-active {
  background: linear-gradient(135deg, var(--brand), #17875f);
  color: white;
}

.field-with-autocomplete {
  position: relative;
}

.autocomplete-list {
  position: static;
  display: grid;
  gap: 4px;
  margin-top: 6px;
  padding: 6px 0;
  border-radius: 14px;
  border: 1px solid rgba(17, 24, 39, 0.12);
  background: white;
  box-shadow: 0 16px 40px rgba(17, 24, 39, 0.12);
  overflow: auto;
  width: 100%;
  min-width: 0;
  max-height: 240px;
}

.autocomplete-empty {
  padding: 10px 14px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.autocomplete-item {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.autocomplete-item:hover,
.autocomplete-item.is-active {
  background: rgba(18, 88, 79, 0.08);
}

.autocomplete-item:focus-visible {
  outline: 2px solid rgba(18, 88, 79, 0.35);
  outline-offset: -2px;
}

.nav-button span {
  white-space: nowrap;
}

.nav-icon {
  font-size: 0.95rem;
  letter-spacing: -0.1em;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 20, 0.48);
  backdrop-filter: blur(10px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: min(86vh, 780px);
  overflow: auto;
  padding: 16px;
  border-radius: var(--radius-xl);
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.modal-header-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
}

.match-modal-date {
  color: var(--ink-soft);
  font-size: 0.92rem;
  white-space: nowrap;
}

.match-modal-title-separator {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.match-score-field {
  margin-top: 10px;
}

.modal-content {
  display: grid;
  gap: 12px;
}

.match-hero {
  display: grid;
  gap: 10px;
}

.match-team-line {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: white;
}

.match-team-line strong {
  font-size: 1.04rem;
}

.match-team-members {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.match-team-elo {
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 700;
}

.match-meta-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.match-meta-item {
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-strong);
  color: var(--ink);
  font-size: 0.95rem;
}

.score-form,
.signup-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.match-create-form {
  display: grid;
  gap: 14px;
}

.team-entry-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.team-entry-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-strong);
}

.team-entry-card h2 {
  margin: 0;
  font-size: 1rem;
}

.score-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.field input,
.field select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--ink);
  background: white;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(15, 106, 76, 0.18);
  border-color: var(--brand);
}

.hint-text {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.hint-text.is-error {
  color: #b13c1d;
}

.hint-text.is-success {
  color: var(--brand);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  z-index: 30;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: calc(100vw - 24px);
  padding: 14px 16px;
  border: 1px solid rgba(15, 106, 76, 0.26);
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--brand), #147455);
  box-shadow: var(--shadow);
  text-align: center;
}

[hidden] {
  display: none !important;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: calc(100vw - 12px);
    padding: 8px 6px 96px;
    box-sizing: border-box;
  }

  body[data-page="tournament"] .page-shell {
    width: 100%;
    padding: 8px 4px 96px;
  }

  .hero-card,
  .view-panel,
  .modal-card {
    border-radius: 22px;
  }

  .view-panel {
    /* kleinere Innenabstände damit Panels breiter werden */
    padding: 12px;
    box-sizing: border-box;
    max-width: 100vw;
    /* verhindert horizontales Überlaufen */
    overflow-x: hidden;
    /* Panel selbst nicht nach außen scrollen lassen */
  }

  .tournament-stage-panel {
    gap: 10px;
    padding: 0 2px;
  }

  .section-heading,
  .modal-header {
    flex-direction: column;
    align-items: stretch;
  }

  .tournament-stage-heading {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
  }

  .tournament-stage-heading .section-action-row {
    flex-direction: column;
    align-items: flex-end;
  }

  .tournament-stage-heading .primary-button,
  .tournament-stage-heading .secondary-button {
    padding: 10px 13px;
    font-size: 0.82rem;
  }

  .bracket-shell {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    margin: 0;
  }

  .bracket-grid {
    /* Mobile: Bracket-Spalten nebeneinander, horizontal scrollen (Swipe) */
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 78vw);
    gap: 12px;
    /* Aktiviert horizontales Einrasten pro Runde */
    scroll-snap-type: x proximity;
  }

  .round-column {
    scroll-snap-align: start;
    min-width: min(78vw, 220px);
    /* Jede Spalte isoliert, damit sich Karten nicht gegenseitig überlagern */
    isolation: isolate;
    position: relative;
  }

  .team-entry-grid,
  .score-grid,
  .match-score-grid-compact {
    grid-template-columns: 1fr;
  }

  /* Kompaktere Match-Karten auf mobilen Geräten */
  .bracket-match {
    padding: 10px;
    min-height: 96px;
    border-radius: 14px;
    gap: 8px;
  }

  .match-team {
    padding: 8px 10px;
  }

  .match-team strong {
    font-size: 0.95rem;
  }

  .match-team-score {
    font-size: 0.95rem;
  }

  .match-title {
    font-size: 0.78rem;
  }

  .tournament-phase-switch {
    gap: 0.22rem;
    margin-top: 0.2rem;
    padding: 0.14rem;
  }

  .tournament-phase-button {
    padding: 0.42rem 0.72rem;
    font-size: 0.8rem;
  }

  .group-overview-card,
  .group-section {
    padding: 0.85rem;
  }

  .group-phase-toolbar {
    position: fixed;
    left: 50%;
    bottom: 84px;
    top: auto;
    transform: translateX(-50%);
    width: calc(100vw - 28px);
    justify-content: center;
    margin-bottom: 0;
    pointer-events: none;
    z-index: 14;
  }

  .group-tables-button {
    pointer-events: auto;
    padding: 0.62rem 0.86rem;
    font-size: 0.8rem;
    box-shadow: 0 10px 22px rgba(17, 24, 39, 0.14);
  }

  .group-section.group-section-detail {
    gap: 0.85rem;
    padding: 0 0 5.75rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .group-section.group-section-detail .group-detail-heading {
    padding: 0 0.1rem;
  }

  .group-table {
    font-size: 0.9rem;
  }

  .group-table th,
  .group-table td {
    padding: 0.55rem 0.5rem;
  }

  .ranking-heading {
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
  }

  .ranking-mode-switch {
    padding: 0.14rem;
  }

  .ranking-mode-button {
    padding: 0.4rem 0.62rem;
    font-size: 0.78rem;
  }

  .bottom-nav {
    width: calc(100vw - 16px);
    padding: 8px;
  }

  .nav-button {
    padding: 9px 8px;
    font-size: 0.8rem;
  }
}

/* Desktop: kompakteres Bracket für viele Runden (16tel, 32er) */
@media (min-width: 1024px) {
  .bracket-grid {
    /* feste Spaltenbreite auf Desktop, verhindert Überlappung */
    grid-auto-columns: 180px;
    gap: 12px;
  }

  .round-column {
    min-width: 180px;
    gap: 10px;
  }

  .bracket-match {
    padding: 10px;
    min-height: 100px;
  }

  .match-team strong {
    font-size: 0.78rem;
  }

  .match-team-meta {
    font-size: 0.68rem;
  }

  .match-team-score {
    font-size: 0.82rem;
    min-width: 36px;
  }
}
