:root {
  --widmann-blue: #2f6fb0;
  --widmann-blue-dark: #173b67;
  --widmann-pink: #d2027b;
  --surface: rgba(255, 255, 255, 0.86);
  --line: rgba(47, 111, 176, 0.2);
  --text: #10213b;
  --muted: #68758b;
}

body.turnier-page {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 12%, rgba(47, 111, 176, 0.16), transparent 32%),
    radial-gradient(circle at 88% 4%, rgba(210, 2, 123, 0.12), transparent 28%),
    linear-gradient(135deg, #edf5fb 0%, #f8fbfe 50%, #e8eff7 100%);
  font-family: "Manrope", sans-serif;
}

.turnier-page .page-shell {
  width: min(100%, 1920px);
  margin: 0 auto;
}

.turnier-tool-back,
.turnier-sidebar-toggle,
.turnier-icon-button {
  position: fixed;
  z-index: 30;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background: linear-gradient(145deg, #214c7b, #3b78b8);
  color: #fff;
  box-shadow: 0 12px 28px rgba(19, 53, 88, 0.25), inset 0 1px 0 rgba(255,255,255,0.45);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.turnier-tool-back {
  top: 22px;
  left: 28px;
}

.turnier-tool-back span::before {
  content: "";
  width: 26px;
  height: 26px;
  display: block;
  background: url("../assets/icons/Application_logo_back.png") center / contain no-repeat;
}

.turnier-sidebar-toggle {
  top: 22px;
  left: 96px;
}

.turnier-tool-back:hover,
.turnier-sidebar-toggle:hover,
.turnier-icon-button:hover {
  transform: translateY(2px) scale(1.08);
  box-shadow: 0 16px 32px rgba(19, 53, 88, 0.32), inset 0 1px 0 rgba(255,255,255,0.6);
}

.turnier-sidebar-toggle .bloom-container,
.turnier-sidebar-toggle .button-container-main,
.turnier-sidebar-toggle .button-inner,
.turnier-sidebar-toggle .back,
.turnier-sidebar-toggle .front {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.turnier-sidebar-toggle .bloom-container {
  pointer-events: none;
}

.turnier-sidebar-toggle .back,
.turnier-sidebar-toggle .button-glass,
.turnier-sidebar-toggle .bloom {
  display: none;
}

.turnier-sidebar-toggle svg {
  width: 28px;
  height: 28px;
  display: block;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  fill: none;
  transform: none;
}

.turnier-actions-top {
  position: fixed;
  top: 22px;
  right: 28px;
  z-index: 30;
  display: flex;
  gap: 12px;
}

.turnier-team-count-control {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 30;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 7px 14px 7px 18px;
  border: 1px solid rgba(47, 111, 176, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 12px 30px rgba(43, 70, 104, 0.14), inset 0 1px 0 rgba(255,255,255,0.82);
  backdrop-filter: blur(12px);
  color: var(--text);
  font-weight: 900;
}

.turnier-team-count-control span {
  font-size: 13px;
  color: #325274;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.turnier-team-count-control input {
  width: 74px;
  min-height: 38px;
  border: 1px solid rgba(47, 111, 176, 0.22);
  border-radius: 999px;
  background: linear-gradient(180deg, #edf3fa, #d8e1ec);
  box-shadow: inset 0 4px 10px rgba(53, 69, 90, 0.12);
  color: var(--widmann-blue-dark);
  font: inherit;
  text-align: center;
}

.turnier-top-logos {
  position: fixed;
  top: 17px;
  left: calc(50% - 275px);
  z-index: 31;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 64px;
  pointer-events: none;
}

.turnier-top-logos img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 12px 20px rgba(16, 33, 59, 0.18));
}

.turnier-top-logos img:first-child {
  width: 102px;
  height: 87px;
  opacity: 0.9;
}

.turnier-top-winner {
  position: fixed;
  top: 84px;
  left: 50%;
  z-index: 28;
  transform: translateX(-50%);
  width: min(280px, 32vw);
}

.turnier-top-winner:has(.turnier-winner-card.has-winner) {
  top: 72px;
  width: min(560px, 58vw);
}

.turnier-top-winner .turnier-winner-card {
  min-height: 58px;
  grid-template-columns: auto minmax(0, 1fr);
  justify-content: center;
  align-items: center;
  padding: 12px 16px 10px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 30px rgba(43, 70, 104, 0.16), inset 0 1px 0 rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
}

.turnier-top-winner .turnier-winner-card.has-winner {
  min-height: 138px;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 22px;
  padding: 24px 30px 22px;
  border-radius: 34px;
  box-shadow: 0 26px 58px rgba(43, 70, 104, 0.22), inset 0 1px 0 rgba(255,255,255,0.92);
}

.turnier-top-winner .turnier-winner-card > span {
  grid-column: 1 / -1;
}

.turnier-top-winner .turnier-team-badge {
  width: 42px;
  border-radius: 14px;
}

.turnier-top-winner .turnier-team-logo {
  width: 42px;
  border-radius: 14px;
}

.turnier-winner-emblem {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  min-height: 56px;
}

.turnier-winner-card.has-winner .turnier-winner-emblem {
  width: 128px;
  min-height: 132px;
}

.turnier-winner-emblem .turnier-team-badge,
.turnier-winner-emblem .turnier-team-logo {
  width: 46px;
  aspect-ratio: 1;
  border-radius: 14px;
}

.turnier-winner-card.has-winner .turnier-winner-emblem .turnier-team-badge,
.turnier-winner-card.has-winner .turnier-winner-emblem .turnier-team-logo {
  width: 112px;
  border-radius: 28px;
}

.turnier-winner-crown {
  position: absolute;
  top: -16px;
  left: 50%;
  z-index: 2;
  width: 34px;
  transform: translateX(-50%) rotate(-6deg);
  filter: drop-shadow(0 5px 8px rgba(43, 70, 104, 0.24));
  pointer-events: none;
}

.turnier-winner-card.has-winner .turnier-winner-crown {
  top: -34px;
  width: 78px;
  filter: drop-shadow(0 10px 14px rgba(43, 70, 104, 0.28));
}

.turnier-winner-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
  text-align: left;
}

.turnier-winner-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.turnier-winner-card.has-winner .turnier-winner-copy strong {
  font-size: 27px;
}

.turnier-winner-players {
  display: grid;
  gap: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
}

.turnier-winner-card.has-winner .turnier-winner-players {
  gap: 4px;
  font-size: 16px;
  line-height: 1.25;
}

.turnier-winner-players span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turnier-icon-button {
  position: relative;
  font-size: 28px;
  font-weight: 900;
  overflow: hidden;
  isolation: isolate;
}

.turnier-icon-button::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,255,255,0.48), transparent 45%, rgba(255,255,255,0.2));
  opacity: 0.72;
  transform: translate(-30%, -30%) rotate(18deg);
  transition: transform 0.28s ease, opacity 0.28s ease;
  pointer-events: none;
  z-index: -1;
}

.turnier-icon-button:hover::before {
  opacity: 1;
  transform: translate(10%, 10%) rotate(18deg);
}

.turnier-icon-button:active {
  transform: scale(0.88);
}

.turnier-icon-button.danger {
  background: linear-gradient(145deg, #b92131, #e23d54);
}

.turnier-layout {
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 92px 14px 18px;
}

.turnier-sidebar-collapsed .turnier-layout {
  grid-template-columns: 0 minmax(0, 1fr);
}

.turnier-sidebar-collapsed .turnier-left-rail {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-24px);
}

.turnier-left-rail {
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.turnier-page .hero-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 12px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.turnier-app-logo {
  position: absolute;
  left: 14px;
  top: -6px;
  width: 58px;
  height: 58px;
  object-fit: contain;
  z-index: 2;
  filter: drop-shadow(0 10px 18px rgba(16, 33, 59, 0.18));
}

.turnier-page .hero-logo {
  width: 74px;
  opacity: 0.18;
  margin-left: 24px;
}

.turnier-page .hero-title {
  margin: 0;
  color: rgba(16, 33, 59, 0.18);
  letter-spacing: 0;
}

.turnier-page .hero-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.turnier-sidebar,
.turnier-main,
.turnier-modal-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(43, 70, 104, 0.13);
}

.turnier-sidebar {
  padding: 18px;
  min-height: calc(100vh - 188px);
}

.turnier-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.turnier-title-row h2,
.turnier-main h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.turnier-sidebar-panel {
  display: none;
}

body[data-turnier-view="library"] .turnier-sidebar-panel[data-sidebar-view="library"],
body[data-turnier-view="plan"] .turnier-sidebar-panel[data-sidebar-view="plan"] {
  display: block;
}

.sidebar-copy {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 650;
  line-height: 1.45;
}

.app-button,
.inline-button {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(47, 111, 176, 0.28);
  border-radius: 999px;
  color: #1f568e;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(241,247,252,0.9));
  box-shadow: 0 8px 18px rgba(25, 58, 91, 0.14), inset 0 1px 0 rgba(255,255,255,0.9);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.app-button + .app-button {
  margin-top: 10px;
}

.app-button:hover,
.inline-button:hover {
  transform: translateY(1px);
  box-shadow: 0 10px 22px rgba(47, 111, 176, 0.22), inset 0 1px 0 rgba(255,255,255,0.95);
}

.primary-button {
  color: #fff;
  background: linear-gradient(180deg, #69a3dc, #2f6fb0);
}

.thin-separator {
  height: 1px;
  margin: 18px 0;
  background: rgba(47, 111, 176, 0.18);
}

.field-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: #465671;
  font-size: 13px;
  font-weight: 850;
}

.input {
  min-height: 48px;
  border: 1px solid rgba(47, 111, 176, 0.2);
  border-radius: 16px;
  background: linear-gradient(180deg, #edf3fa, #d8e1ec);
  color: var(--text);
  padding: 0 16px;
  font: inherit;
  box-shadow: inset 0 4px 10px rgba(53, 69, 90, 0.12);
}

textarea.input {
  padding-top: 12px;
  resize: vertical;
}

.turnier-team-roster textarea.input {
  min-height: 124px;
}

.turnier-color-field {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.turnier-color-input {
  width: 58px;
  height: 48px;
  padding: 4px;
  border: 1px solid rgba(47, 111, 176, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 3px 8px rgba(53, 69, 90, 0.12), 0 10px 22px rgba(43, 70, 104, 0.12);
  cursor: pointer;
}

.turnier-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.turnier-color-input::-webkit-color-swatch {
  border: 0;
  border-radius: 12px;
}

.turnier-player-editor {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  color: #465671;
  font-size: 13px;
  font-weight: 850;
}

.turnier-player-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.turnier-player-labels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 4px;
  color: #6b7890;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.turnier-modal-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 14px;
  border: 1px solid rgba(47, 111, 176, 0.18);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(232,243,253,0.72));
  box-shadow: 0 12px 26px rgba(43, 70, 104, 0.1);
}

.turnier-modal-preview span {
  width: 42px;
  aspect-ratio: 1;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--team-color, #2f6fb0), #10213b);
  font-weight: 900;
  box-shadow: 0 12px 24px color-mix(in srgb, var(--team-color, #2f6fb0), transparent 55%);
}

.turnier-modal-preview img {
  width: 46px;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 14px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 24px rgba(43, 70, 104, 0.14);
}

.turnier-modal-preview strong {
  font-weight: 900;
}

.turnier-modal-preview small {
  margin-left: auto;
  color: var(--muted);
  font-weight: 800;
}

.turnier-logo-upload {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.turnier-logo-upload small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-weight: 700;
}

.turnier-sidebar-teams {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.turnier-sidebar-teams .turnier-team-card {
  grid-template-columns: 34px minmax(0, 1fr);
  min-height: 72px;
  padding: 7px;
  border-radius: 14px;
  gap: 8px;
}

.turnier-sidebar-teams .turnier-team-badge {
  width: 32px;
  border-radius: 11px;
  font-size: 11px;
}

.turnier-sidebar-teams .turnier-team-logo {
  width: 32px;
  border-radius: 11px;
  padding: 3px;
}

.turnier-sidebar-teams .turnier-team-copy strong {
  font-size: 12px;
  line-height: 1.15;
}

.turnier-sidebar-teams .turnier-team-copy span {
  display: none;
}

.turnier-sidebar-teams .turnier-team-copy p {
  display: -webkit-box;
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.22;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.status-list {
  margin-top: 18px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.55;
}

.turnier-main {
  min-height: calc(100vh - 112px);
  padding: 24px;
  overflow: hidden;
}

.turnier-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.turnier-view-switch {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(47, 111, 176, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 10px 26px rgba(43, 70, 104, 0.12);
}

.turnier-view-switch-top {
  position: fixed;
  top: 26px;
  left: calc(50% + 170px);
  z-index: 30;
}

.turnier-main-header .turnier-view-switch {
  display: none;
}

.turnier-view-switch label {
  position: relative;
  cursor: pointer;
  transition: transform 0.18s ease;
}

.turnier-view-switch label:hover {
  transform: translateY(2px) scale(1.04);
}

.turnier-view-switch label:active {
  transform: translateY(3px) scale(0.94);
}

.turnier-view-switch input {
  position: absolute;
  opacity: 0;
}

.turnier-view-switch span {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  min-width: 130px;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 900;
  color: var(--text);
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.turnier-view-switch span::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(110deg, transparent 0%, rgba(255,255,255,0.78) 42%, transparent 72%);
  opacity: 0;
  transform: translateX(-85%);
  transition: transform 0.45s ease, opacity 0.22s ease;
  pointer-events: none;
}

.turnier-view-switch label:hover span::after,
.turnier-view-switch input:checked + span::after {
  opacity: 0.78;
  transform: translateX(85%);
}

.turnier-view-switch input:checked + span {
  color: #1f568e;
  background: rgba(232, 243, 253, 0.92);
  box-shadow: inset 0 0 0 1px rgba(47, 111, 176, 0.12), 0 10px 22px rgba(47, 111, 176, 0.16);
  transform: scale(1.03);
}

.turnier-view {
  display: none;
}

.turnier-view.is-active {
  display: block;
}

.turnier-library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 16px;
}

.turnier-team-card {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 120px;
  padding: 16px;
  border: 1px solid rgba(47, 111, 176, 0.18);
  border-radius: 20px;
  background: rgba(255,255,255,0.86);
  box-shadow: 0 16px 36px rgba(43, 70, 104, 0.1);
  cursor: grab;
}

.turnier-team-card:active {
  cursor: grabbing;
}

.turnier-team-badge {
  width: 58px;
  aspect-ratio: 1;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--team-color, #2f6fb0), #10213b);
  font-weight: 900;
  box-shadow: 0 12px 24px color-mix(in srgb, var(--team-color, #2f6fb0), transparent 55%);
}

.turnier-team-logo {
  width: 58px;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 18px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 24px rgba(43, 70, 104, 0.14);
}

.turnier-sidebar-teams .turnier-team-logo {
  width: 32px;
  border-radius: 11px;
  padding: 3px;
}

.turnier-team-copy strong {
  display: block;
  font-size: 18px;
  font-weight: 900;
}

.turnier-team-copy span {
  color: #2f6fb0;
  font-size: 13px;
  font-weight: 900;
}

.turnier-team-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.turnier-board {
  --tree-scale: 1;
  --tree-gap: 46px;
  --game-pad: 12px;
  --slot-min: 50px;
  --slot-pad: 7px;
  --team-font: 14px;
  --score-width: 58px;
  position: relative;
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.92fr;
  gap: var(--tree-gap);
  align-items: center;
  min-height: 680px;
  overflow: visible;
}

.turnier-lines-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}

.turnier-line-path {
  fill: none;
  stroke: rgba(47, 111, 176, 0.34);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.turnier-board.is-wide {
  grid-template-columns: repeat(var(--wide-columns, 7), minmax(132px, 1fr));
  align-items: center;
  gap: var(--tree-gap);
  min-height: calc(720px * var(--tree-scale));
}

.turnier-board.size-8 {
  --tree-scale: 1;
}

.turnier-board.size-10,
.turnier-board.size-12 {
  --tree-scale: 0.94;
  --tree-gap: 14px;
  --game-pad: 10px;
  --slot-min: 46px;
  --slot-pad: 6px;
  --team-font: 13px;
  --score-width: 52px;
}

.turnier-board.size-14,
.turnier-board.size-16 {
  --tree-scale: 0.86;
  --tree-gap: 10px;
  --game-pad: 8px;
  --slot-min: 40px;
  --slot-pad: 5px;
  --team-font: 12px;
  --score-width: 46px;
}

.turnier-board.size-18,
.turnier-board.size-20 {
  --tree-scale: 0.78;
  --tree-gap: 6px;
  --game-pad: 6px;
  --slot-min: 34px;
  --slot-pad: 4px;
  --team-font: 11px;
  --score-width: 40px;
}

.turnier-board.size-18 .turnier-round h3,
.turnier-board.size-20 .turnier-round h3,
.turnier-board.size-18 .turnier-side h3,
.turnier-board.size-20 .turnier-side h3 {
  margin-bottom: 8px;
  font-size: 11px;
}

.turnier-board.size-18 .turnier-winner-button,
.turnier-board.size-20 .turnier-winner-button {
  min-height: 24px;
  padding: 0 8px;
  font-size: 10px;
}

.turnier-board.size-18 .turnier-drop-hint,
.turnier-board.size-20 .turnier-drop-hint {
  font-size: 10px;
}

.turnier-side {
  position: relative;
  overflow: visible;
}

.turnier-side-round {
  min-width: 0;
}

.turnier-round h3 {
  margin: 0 0 14px;
  color: var(--widmann-pink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 13px;
  font-weight: 900;
}

.turnier-round-games {
  display: grid;
  gap: calc(18px * var(--tree-scale));
  overflow: visible;
}

.turnier-board.size-16 .turnier-side-r2 .turnier-round-games {
  gap: calc(210px * var(--tree-scale));
  padding-top: calc(86px * var(--tree-scale));
}

.turnier-board.size-16 .turnier-side-r3 .turnier-round-games {
  padding-top: calc(236px * var(--tree-scale));
}

.turnier-round {
  position: relative;
  overflow: visible;
  font-size: var(--team-font);
}

.turnier-round-sf .turnier-round-games {
  gap: calc(74px * var(--tree-scale));
}

.turnier-round-final .turnier-round-games {
  gap: 0;
}

.turnier-round-final,
.turnier-center-final {
  align-self: center;
  justify-self: center;
  width: min(100%, 320px);
}

.turnier-board.is-wide .turnier-center-final {
  width: min(100%, 260px);
}

.turnier-board.is-wide .turnier-game {
  border-radius: 16px;
}

.turnier-game {
  position: relative;
  z-index: 2;
  display: grid;
  gap: calc(8px * var(--tree-scale));
  padding: var(--game-pad);
  border: 1px solid rgba(47, 111, 176, 0.18);
  border-radius: 20px;
  background: rgba(255,255,255,0.76);
  box-shadow: 0 12px 28px rgba(43, 70, 104, 0.09);
}

.turnier-game-connected::before,
.turnier-game-connected::after,
.turnier-game-label::before,
.turnier-game-label::after {
  display: none !important;
}

.turnier-game-connected::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(var(--tree-gap) + 10px);
  border-top: 2px solid rgba(47, 111, 176, 0.32);
  pointer-events: none;
  z-index: -1;
}

.turnier-game-connected.connect-right::after {
  left: calc(100% + 1px);
}

.turnier-game-connected.connect-left::after {
  right: calc(100% + 1px);
}

.turnier-round-final .turnier-game::after,
.turnier-center-final .turnier-game::after {
  display: none;
}

.turnier-round-qf .turnier-game:nth-child(odd)::before,
.turnier-round-sf .turnier-game:nth-child(odd)::before,
.turnier-side-left .turnier-game:nth-child(odd)::before,
.turnier-side-round.is-left .turnier-game:nth-child(odd)::before {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(100% + var(--tree-gap) + 10px);
  height: calc(100% + (18px * var(--tree-scale)));
  border-right: 2px solid rgba(47, 111, 176, 0.32);
  pointer-events: none;
  z-index: -1;
}

.turnier-round-qf .turnier-game:nth-child(odd)::before {
  height: calc(100% + (18px * var(--tree-scale)));
}

.turnier-round-sf .turnier-game:nth-child(odd)::before {
  height: calc(100% + (74px * var(--tree-scale)));
}

.turnier-side-right .turnier-game:nth-child(odd)::before,
.turnier-side-round.is-right .turnier-game:nth-child(odd)::before {
  content: "";
  position: absolute;
  top: 50%;
  right: calc(100% + var(--tree-gap) + 10px);
  height: calc(100% + (18px * var(--tree-scale)));
  border-left: 2px solid rgba(47, 111, 176, 0.32);
  pointer-events: none;
  z-index: -1;
}

.turnier-side-round .turnier-game:nth-last-child(1):nth-child(odd)::before {
  display: none;
}

.turnier-side-final .turnier-game::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 28px;
  border-top: 2px solid rgba(47, 111, 176, 0.32);
  pointer-events: none;
  z-index: -1;
}

.turnier-side-final-left .turnier-game::before {
  left: 100%;
}

.turnier-side-final-right .turnier-game::before {
  right: 100%;
}

.turnier-game-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.turnier-round-sf .turnier-game-label::before,
.turnier-round-final .turnier-game-label::before {
  content: "";
  position: absolute;
  top: 50%;
  left: calc((var(--tree-gap) + 10px) * -1);
  width: calc(var(--tree-gap) + 10px);
  border-top: 2px solid rgba(47, 111, 176, 0.32);
  pointer-events: none;
  z-index: -1;
}

.turnier-round-final .turnier-game-label::before {
  left: calc((var(--tree-gap) + 10px) * -1);
  width: calc(var(--tree-gap) + 10px);
}

.turnier-side-round.has-incoming.is-left .turnier-game-label::before,
.turnier-side-round.has-incoming.is-right .turnier-game-label::before {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(var(--tree-gap) + 10px);
  border-top: 2px solid rgba(47, 111, 176, 0.32);
  pointer-events: none;
  z-index: -1;
}

.turnier-side-round.has-incoming.is-left .turnier-game-label::before {
  left: calc((var(--tree-gap) + 10px) * -1);
}

.turnier-side-round.has-incoming.is-right .turnier-game-label::before {
  right: calc((var(--tree-gap) + 10px) * -1);
}

.turnier-center-final .turnier-game-label::before,
.turnier-center-final .turnier-game-label::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(var(--tree-gap) + 10px);
  border-top: 2px solid rgba(47, 111, 176, 0.32);
  pointer-events: none;
  z-index: -1;
}

.turnier-center-final .turnier-game-label::before {
  left: calc((var(--tree-gap) + 10px) * -1);
}

.turnier-center-final .turnier-game-label::after {
  right: calc((var(--tree-gap) + 10px) * -1);
}

.turnier-slot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--score-width);
  gap: 8px;
  align-items: center;
  min-height: var(--slot-min);
  padding: var(--slot-pad);
  border: 1px dashed rgba(47, 111, 176, 0.28);
  border-radius: 15px;
  background: rgba(240, 247, 253, 0.72);
}

.turnier-slot-disabled {
  grid-template-columns: 1fr;
  opacity: 0.55;
  pointer-events: none;
}

.turnier-slot.is-drag-over,
.turnier-winner-card.is-drag-over {
  border-color: var(--widmann-pink);
  box-shadow: 0 0 0 4px rgba(210, 2, 123, 0.1);
}

.turnier-slot-team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: calc(30px + (6px * var(--tree-scale)));
  border-radius: 12px;
  padding: 8px 8px 8px 12px;
  color: #fff;
  background: linear-gradient(145deg, var(--team-color, #2f6fb0), #173b67);
  font-weight: 900;
  font-size: var(--team-font);
  cursor: grab;
}

.turnier-slot-team button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: rgba(255,255,255,0.86);
  cursor: pointer;
}

.turnier-drop-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.turnier-score-input {
  width: var(--score-width);
  min-height: 36px;
  border: 1px solid rgba(47, 111, 176, 0.22);
  border-radius: 12px;
  text-align: center;
  font-weight: 900;
  color: var(--text);
  background: #fff;
}

.turnier-winner-button {
  width: auto;
  justify-self: end;
  min-height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

.turnier-champion {
  align-self: center;
}

.turnier-winner-card {
  min-height: 170px;
  border: 1px dashed rgba(210, 2, 123, 0.32);
  border-radius: 24px;
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
  background: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(255,239,248,0.85));
  color: var(--text);
  font-weight: 900;
}

.turnier-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(16, 33, 59, 0.32);
  backdrop-filter: blur(8px);
}

.turnier-modal-backdrop[hidden] {
  display: none;
}

.turnier-modal-card {
  width: min(1180px, 96vw);
  padding: 24px;
}

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

.modal-header h2 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 900;
}

.modal-header p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.turnier-close-button {
  width: 40px;
  min-height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
}

.turnier-form {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.15fr);
  gap: 22px;
  align-items: start;
}

.turnier-team-column {
  display: grid;
  gap: 14px;
  min-width: 0;
  align-content: start;
}

.turnier-team-column .field-stack,
.turnier-team-column .turnier-player-editor {
  margin-bottom: 0;
}

.turnier-span-2,
.modal-actions {
  grid-column: 1 / -1;
}

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

.modal-actions .inline-button {
  width: auto;
  min-width: 130px;
  padding: 0 18px;
}

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

  .turnier-sidebar-collapsed .turnier-layout {
    grid-template-columns: 1fr;
  }

  .turnier-sidebar-collapsed .turnier-left-rail {
    display: none;
  }

  .turnier-board,
  .turnier-library-grid {
    grid-template-columns: 1fr;
  }
}
