/* =========================================================
   HCue – Turnierplaner (eigenes Stylesheet)
   ========================================================= */
.tour-main { width: 100%; max-width: 1100px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; align-content: start; }
.tour-main .card { display: grid; gap: .7rem; align-content: start; }
.tour-main .card > * { min-width: 0; }

.tour-hub-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.tour-hub-head h2, .tour-hub-head h3 { margin: 0; }
.tour-view-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Hub-Liste */
.tour-list { display: grid; gap: .45rem; }
.tour-list-item {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem; width: 100%;
  text-align: left; background: var(--bg-inset); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .8rem; color: var(--text); cursor: pointer; font: inherit;
}
.tour-list-item:hover { border-color: var(--accent); }
.tour-li-name { font-weight: 600; }

/* Status-Badges */
.tour-status { display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: .05rem .5rem; border: 1px solid var(--line); vertical-align: middle; }
.tour-status.s-prep { color: var(--text-dim); }
.tour-status.s-registration { color: var(--accent-strong); border-color: var(--accent); }
.tour-status.s-running { color: #ffd166; border-color: #ffd166; }
.tour-status.s-finished { color: var(--ok); border-color: var(--ok); }
.tour-status.s-cancelled { color: #ffb3b0; border-color: var(--danger); }

/* Editor-Formular */
.tour-editor label { display: block; }
.tour-editor .tour-label { display: block; font-size: .82rem; color: var(--text-dim); margin: .2rem 0 .25rem; }
.tour-grid2 { display: grid; gap: .7rem; }
@media (min-width: 560px) { .tour-grid2 { grid-template-columns: 1fr 1fr; align-items: end; } }
.tour-fs { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; display: grid; gap: .6rem; }
.tour-fs legend { padding: 0 .35rem; font-weight: 600; font-size: .9rem; }
.tour-disc { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.chk { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; }
.chk-inline { align-self: end; }
.tour-stage { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem; margin-bottom: .5rem; }
.tour-stage .st-from { flex: 1 1 120px; }
.tour-stage .st-mode { flex: 1 1 150px; }
.tour-stage .st-race { flex: 0 0 auto; }
.tour-stage .st-race input { width: 80px; }

/* Rich-Text-Editor */
.rte-toolbar { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .3rem; }
.rte-toolbar button {
  background: var(--bg-inset); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .3rem .55rem; cursor: pointer; min-width: 2rem; font-size: .85rem;
}
.rte-toolbar button:hover { border-color: var(--accent); }
.rte {
  min-height: 8rem; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem;
  background: var(--bg-inset); overflow-wrap: anywhere;
}
.rte:focus { outline: none; border-color: var(--accent); }
.rte p { margin: 0 0 .5rem; }

/* Teilnehmer */
.tour-players-list { margin: 0; padding-left: 1.4rem; display: grid; gap: .3rem; }
.tour-players-list li { padding-right: 1.4rem; position: relative; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.tour-pl-name { font-weight: 500; }
/* Startgebühr-Chip: grau = offen, grün = bezahlt/offiziell gemeldet */
.tour-paid {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.5rem; height: 1.4rem; padding: 0 .35rem; font-size: .78rem; font-weight: 700;
  border: 1px solid var(--line); border-radius: 999px; background: transparent;
  color: var(--text-dim); cursor: default;
}
button.tour-paid { cursor: pointer; }
button.tour-paid:hover { border-color: var(--ok); }
.tour-paid.on { color: var(--ok); border-color: var(--ok); background: rgba(63,174,106,.12); }

/* Einklappbare Bereiche (Beschreibung/Teilnehmer bei laufendem Turnier).
   Eigener Pfeil-Marker, damit er bündig mit dem übrigen Karteninhalt steht. */
.tour-acc > summary {
  cursor: pointer; font-weight: 700; font-size: 1.02rem;
  list-style: none; display: flex; align-items: center; gap: .45rem;
}
.tour-acc > summary::-webkit-details-marker { display: none; }
.tour-acc > summary::before {
  content: '▸'; color: var(--text-dim); flex: 0 0 auto;
  transition: transform .15s ease;
}
.tour-acc[open] > summary::before { transform: rotate(90deg); }
.tour-acc > summary:hover { color: var(--accent-strong); }
.tour-acc[open] > summary { margin-bottom: .6rem; }

/* ---------- Teilnehmer-Bereich: Liste + Preisgeld-Kalkulation nebeneinander ---------- */
.tour-participants-grid { display: grid; gap: 1.2rem; align-items: start; }
@media (min-width: 780px) { .tour-participants-grid { grid-template-columns: 1fr 1fr; } }
.tour-pl-date { font-size: .76rem; margin-left: auto; white-space: nowrap; }

/* Preisgeld-Panel */
.tour-prize { display: grid; gap: .5rem; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; background: var(--bg-inset); }
.tour-prize h4 { margin: 0; font-size: .95rem; }
.tour-prize .tour-inline-num input { width: 84px; }
.tour-prize-table td:first-child { text-align: left; width: auto; color: var(--text); }
.tour-prize-table td:not(:first-child), .tour-prize-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tour-prize-table tbody tr:first-child td { font-weight: 700; }
.tour-prize-note { margin: 0; font-size: .78rem; }

/* Preisgeld-Zeilen im Editor (Label + Prozent/Betrag + Entfernen) */
.tour-prize-edit { display: flex; align-items: center; gap: .5rem; }
.tour-prize-edit .pz-label { flex: 1 1 160px; }
.tour-prize-edit .pz-num { display: inline-flex; align-items: center; gap: .3rem; flex: 0 0 auto; }
.tour-prize-edit .pz-num input { width: 84px; }
.tour-prize-edit .pz-num span { color: var(--text-dim); }
.tour-x { position: absolute; right: 0; top: 0; background: none; border: 0; color: var(--text-dim); cursor: pointer; }
.tour-x:hover { color: #ffb3b0; }
.tour-addplayer { display: flex; gap: .5rem; flex-wrap: wrap; align-items: start; }
.tour-ap-field { position: relative; flex: 1 1 220px; }
.tour-ap-field input { width: 100%; }
/* Benutzer-Vorschläge (wie im Scoreboard) */
.tour-sugg {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: var(--bg-raised); border: 1px solid var(--accent); border-radius: 8px;
  margin-top: 2px; overflow: hidden; box-shadow: var(--shadow);
}
.tour-sugg button { display: block; width: 100%; text-align: left; border: 0; border-radius: 0; background: transparent; color: var(--text); padding: .45rem .6rem; cursor: pointer; font: inherit; }
.tour-sugg button:hover { background: rgba(79,155,220,.18); }
.tour-badge {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .72rem; align-self: center;
  color: var(--accent-strong); border: 1px solid var(--accent); border-radius: 999px;
  padding: .12rem .55rem; background: rgba(79,155,220,.12);
}
.tour-badge button { border: 0; background: transparent; color: inherit; padding: 0 .1rem; font-size: .9rem; line-height: 1; cursor: pointer; }

/* Tischbeschreibungen im Editor */
.tour-tabledesc { display: grid; gap: .4rem; }
.tour-td-row { display: grid; grid-template-columns: minmax(70px, auto) 1fr; align-items: center; gap: .5rem; }
.tour-td-row > span { font-size: .82rem; color: var(--text-dim); }

/* Beschreibung (gerendert) */
.tour-desc { border-top: 1px solid var(--line); padding-top: .6rem; overflow-wrap: anywhere; }
.tour-desc img { max-width: 100%; height: auto; }
.tour-sub { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; }

/* ---------- Turnierbaum (responsiv) ---------- */
.bracket-scroll { overflow-x: auto; padding-bottom: .4rem; }
.bracket { display: inline-flex; gap: 1.4rem; align-items: stretch; min-width: min-content; }
.bracket-col { display: flex; flex-direction: column; justify-content: space-around; gap: .8rem; min-width: 190px; }
.bracket-round {
  font-size: .78rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .06em; text-align: center; display: flex; align-items: center; gap: .5rem;
}
.bracket-round::before, .bracket-round::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.bracket-match {
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-inset);
  overflow: hidden; position: relative; box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.bracket-match:hover { border-color: var(--accent); }
.bracket-match.is-active { border-color: #ffd166; box-shadow: 0 0 0 2px rgba(255,209,102,.3); }
.bracket-match.is-done { opacity: .96; }
.bm-row { display: flex; align-items: center; gap: .4rem; padding: .45rem .6rem; border-top: 1px solid var(--line); }
.bm-row:first-of-type { border-top: 0; }
.bm-row.win { background: linear-gradient(90deg, rgba(63,174,106,.22), rgba(63,174,106,.08)); box-shadow: inset 3px 0 0 var(--ok); }
.bm-row.win .bm-name { font-weight: 700; }
.bm-row.tbd .bm-name { color: var(--text-dim); font-style: italic; }
.bm-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-score { font-variant-numeric: tabular-nums; color: var(--text-dim); }
.bm-winbtn { background: none; border: 1px solid var(--line); border-radius: 5px; color: var(--ok); cursor: pointer; padding: 0 .3rem; font-size: .8rem; }
.bm-winbtn:hover { border-color: var(--ok); }
.bm-actions { padding: .4rem .55rem; border-top: 1px dashed var(--line); }
.bm-actions .ghost-btn { width: 100%; padding: .3rem; font-size: .82rem; }
.bm-live { display: block; text-align: center; font-size: .68rem; font-weight: 700; color: #ffd166; padding: .15rem; letter-spacing: .05em; }
.bm-table { position: absolute; top: 0; right: 0; font-size: .62rem; background: var(--line); color: var(--text-dim); padding: 0 .3rem; border-bottom-left-radius: 5px; }
.bm-race { font-size: .62rem; background: var(--line); color: var(--text-dim); padding: 0 .3rem; border-radius: 5px; font-variant-numeric: tabular-nums; }
.bracket-match .bm-race { position: absolute; top: 0; left: 0; border-radius: 0 0 5px 0; }

/* Scoreboard-Code der Partie (öffnet das Board: Spieler bearbeitend, Dritte lesend) */
.bm-code {
  display: inline-flex; align-items: center; gap: .25rem; font-size: .74rem; font-weight: 700;
  letter-spacing: .06em; font-variant-numeric: tabular-nums; text-decoration: none;
  color: var(--accent-strong); border: 1px solid var(--accent); border-radius: 999px;
  padding: .08rem .5rem; background: rgba(79,155,220,.12);
}
.bm-code:hover { background: rgba(79,155,220,.22); }
.bracket-match .bm-actions .bm-code { width: 100%; justify-content: center; }

/* ---------- Siegerpodest ---------- */
.tour-podium-card { text-align: center; }
.podium { display: grid; grid-template-columns: 1fr 1.2fr 1fr; align-items: end; gap: .5rem; max-width: 460px; margin: .4rem auto 0; }
.podium-place { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.podium-name { font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; }
.podium-crown { font-size: 1.4rem; }
.podium-bar { width: 100%; border-radius: 8px 8px 0 0; display: flex; align-items: center; justify-content: center; color: #14171c; font-weight: 800; }
.podium .p1 .podium-bar { height: 96px; background: linear-gradient(180deg, #ffe08a, #f5c542); }
.podium .p2 .podium-bar { height: 68px; background: linear-gradient(180deg, #dfe6ee, #b9c3cf); }
.podium .p3 .podium-bar { height: 48px; background: linear-gradient(180deg, #e2a877, #c9814e); }
.tour-results { margin-top: .8rem; text-align: left; }
.tour-results summary { cursor: pointer; font-weight: 600; }
.tour-results ol { margin: .5rem 0 0; padding-left: 1.3rem; display: grid; gap: .25rem; }
.tour-results li { font-size: .88rem; }

/* ---------- Modus-Hinweis + Werkzeuge ---------- */
.tour-modenote { margin: 0; }
.tour-struct-toolbar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: .55rem .8rem; background: var(--bg-raised);
}
#tour-structure { display: grid; gap: 1rem; }
.tour-inline-num { display: inline-flex; align-items: center; gap: .5rem; }
.tour-inline-num input { width: 72px; }
.tour-inline-num select { width: auto; }

/* ---------- Öffentliche Turnierseite (Hero) ---------- */
.tour-hero {
  background:
    radial-gradient(1200px 300px at 15% -80%, rgba(79,155,220,.28), transparent 70%),
    var(--bg-raised);
  border-color: rgba(79,155,220,.35);
}
.tour-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.tour-hero-lead { min-width: 0; }
.tour-hero .tour-title { margin: .35rem 0 .1rem; font-size: clamp(1.4rem, 3.5vw, 2rem); line-height: 1.15; overflow-wrap: anywhere; }
.tour-hero-type { margin: 0; color: var(--text-dim); font-size: .95rem; }
.tour-chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.tour-chip {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .84rem;
  border: 1px solid var(--line); border-radius: 999px; padding: .28rem .75rem;
  background: var(--bg-inset); white-space: nowrap; max-width: 100%;
}
.tour-chip .tc-ico { flex: 0 0 auto; }
.tour-chip .tc-sub { color: var(--text-dim); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; }
.tour-stageflow { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.tour-stage-pill {
  display: inline-flex; flex-direction: column; gap: .05rem;
  border: 1px solid rgba(79,155,220,.45); border-radius: 10px; padding: .4rem .7rem;
  background: rgba(79,155,220,.10); font-size: .84rem; line-height: 1.25;
}
.tour-stage-pill b { color: var(--accent-strong); }
.tour-stage-pill span { color: var(--text-dim); font-size: .76rem; }
.tour-stage-arrow { color: var(--text-dim); font-weight: 700; }
.tour-hero-cta { display: flex; justify-content: flex-start; }
.tour-hero-cta .primary-btn { padding: .6rem 1.4rem; font-size: 1rem; }

/* ---------- Finalrunden-Formular (Modiwechsel) ---------- */
.tour-finals-form { display: flex; flex-wrap: wrap; align-items: end; gap: .8rem; }
.tour-finals-form .tour-inline-num { display: grid; gap: .25rem; }
.tour-finals-form .tour-inline-num > span { font-size: .82rem; color: var(--text-dim); }

/* ---------- Editor: Stufen + Spielstätten + Löschen ---------- */
.tour-stage .st-fixed {
  flex: 1 1 120px; align-self: center; font-size: .88rem; color: var(--text-dim);
  border: 1px dashed var(--line); border-radius: 8px; padding: .5rem .65rem; text-align: center;
}
.tour-venue-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.tour-editor-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.danger-btn { color: #ffb3b0; border-color: rgba(255,107,107,.55); }
.danger-btn:hover { border-color: var(--danger); background: rgba(255,107,107,.12); }

/* ---------- Tabellen (Round-Robin / Gruppen) ---------- */
.tour-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tour-table th, .tour-table td { text-align: center; padding: .32rem .4rem; border-bottom: 1px solid var(--line); }
.tour-table th:nth-child(2), .tour-table td:nth-child(2) { text-align: left; overflow-wrap: anywhere; }
.tour-table th { color: var(--text-dim); font-size: .78rem; font-weight: 700; }
.tour-table td:first-child { color: var(--text-dim); width: 1.6rem; }
.tour-table tr.st-lead td { font-weight: 700; }
.tour-table tr.st-lead td:first-child { color: var(--ok); }

/* ---------- Gruppen ---------- */
.tour-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .9rem; }
.tour-group { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; display: grid; gap: .5rem; background: var(--bg-inset); }
.tour-group h4 { margin: 0; font-size: .95rem; }
.tour-group-matches { display: grid; gap: .4rem; }

/* ---------- Spielplan (flache Liste aller Partien) ---------- */
.tour-plan { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .5rem; }

/* ---------- Kompakte Partie-Zeile ---------- */
.tour-mline { position: relative; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-inset); padding: .4rem .55rem; display: grid; gap: .35rem; transition: border-color .15s ease; }
.tour-mline:hover { border-color: var(--accent); }
.tour-mline.is-active { border-color: #ffd166; box-shadow: 0 0 0 2px rgba(255,209,102,.25); }
.tour-mline.is-done { opacity: .95; }
.tour-mline .ml-head:empty { display: none; }
.ml-pair { display: flex; align-items: center; gap: .4rem; }
.ml-side { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: .3rem; }
.ml-side:last-of-type { justify-content: flex-end; text-align: right; }
.ml-side.win .ml-name { font-weight: 700; }
.ml-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-score { font-variant-numeric: tabular-nums; color: var(--text-dim); }
.ml-vs { color: var(--text-dim); flex: 0 0 auto; }
.tour-mline .bm-start { width: 100%; padding: .3rem; font-size: .82rem; }
.tour-mline .bm-table { position: static; border-radius: 5px; align-self: start; justify-self: start; }
.tour-mline .ml-head { display: flex; gap: .4rem; align-items: center; }
.tour-mline .bm-live { display: inline; padding: 0; }
