/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border: 1px solid var(--c-ink);
  background: var(--c-ink);
  color: #fff;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    transform var(--t-fast),
    background var(--t-fast);
  border-radius: var(--r-sm);
}
.btn:hover {
  background: var(--c-bg-dark-elev);
}
.btn:active {
  transform: translateY(1px);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--c-ink);
}
.btn--ghost:hover {
  background: var(--c-bg-elev);
}

.btn--danger {
  background: var(--c-red);
  border-color: var(--c-red);
}
.btn--danger:hover {
  background: var(--c-red-deep);
  border-color: var(--c-red-deep);
}

.btn--sm {
  padding: var(--s-1) var(--s-3);
  font-size: var(--fs-xs);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 2px var(--s-2);
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  border-radius: var(--r-xs);
  background: var(--c-bg-elev);
  color: var(--c-ink);
  border: var(--b-1);
}
.badge--live {
  background: var(--c-red);
  color: #fff;
  border-color: var(--c-red);
}
.badge--live::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ===== Stat (Kennzahl-Karte) ===== */
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-4);
  background: var(--c-bg-elev);
  border: var(--b-1);
  border-radius: var(--r-sm);
}
.stat__label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-muted);
  font-weight: var(--fw-medium);
}
.stat__value {
  font-family: var(--f-mono);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--c-ink);
  line-height: 1;
}
.stat__hint {
  font-size: var(--fs-xs);
  color: var(--c-subtle);
}

/* ===== Empty ===== */
.empty {
  padding: var(--s-10) var(--s-6);
  text-align: center;
  color: var(--c-muted);
}
.empty__kanji {
  font-size: var(--fs-3xl);
  color: var(--c-red);
  opacity: 0.1;
  font-weight: var(--fw-black);
  margin-bottom: var(--s-2);
}

/* ===== Toast ===== */
#toast-root {
  position: fixed;
  top: var(--s-4);
  right: var(--s-4);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 280px;
  padding: var(--s-3) var(--s-4);
  background: var(--c-ink);
  color: #fff;
  font-size: var(--fs-sm);
  border-left: 3px solid var(--c-ink);
  border-radius: var(--r-sm);
  box-shadow: var(--e-2);
  animation: toast-in var(--t-base);
}
.toast--success {
  border-left-color: var(--c-success);
}
.toast--error {
  border-left-color: var(--c-red);
}
.toast--info {
  border-left-color: var(--c-info);
}
@keyframes toast-in {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  animation: fade-in var(--t-base);
}
.modal {
  background: var(--c-bg-elev);
  border-radius: var(--r-sm);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  border-top: 3px solid var(--c-red);
}
.modal__head {
  padding: var(--s-4) var(--s-6);
  border-bottom: var(--b-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal__title {
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.modal__body {
  padding: var(--s-6);
}
.modal__foot {
  padding: var(--s-4) var(--s-6);
  border-top: var(--b-1);
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ===== Form ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin-bottom: var(--s-4);
}
.field__label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
  font-weight: var(--fw-semibold);
}
.input {
  padding: var(--s-2) var(--s-3);
  background: var(--c-bg-elev);
  border: var(--b-1);
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  transition:
    border-color var(--t-fast),
    box-shadow var(--t-fast);
}
.input:focus {
  outline: none;
  border-color: var(--c-ink);
  box-shadow: var(--e-red);
}
.input[aria-invalid='true'] {
  border-color: var(--c-red);
}
.field__error {
  color: var(--c-red);
  font-size: var(--fs-xs);
}

/* ===== Table ===== */
.table-wrap {
  background: var(--c-bg-elev);
  border: var(--b-1);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  text-align: left;
  padding: var(--s-3) var(--s-4);
  border-bottom: var(--b-1);
  font-size: var(--fs-sm);
  vertical-align: middle;
}
.table th {
  background: var(--c-bg);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
  font-weight: var(--fw-semibold);
}
.table tr:last-child td {
  border-bottom: 0;
}
.table .tr--live {
  background: linear-gradient(90deg, rgba(230, 57, 70, 0.06), transparent 70%);
}
.table__num {
  font-family: var(--f-mono);
  font-weight: var(--fw-semibold);
}

/* ===== LiveBar (Top-Bar Tatami-Chips) ===== */
.livebar {
  display: flex;
  gap: var(--s-2);
  align-items: center;
}
.livebar__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-3);
  background: var(--c-bg-dark-elev);
  color: #fff;
  border-radius: var(--r-xs);
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color var(--t-fast);
}
.livebar__chip:hover {
  border-color: var(--c-red);
}
.livebar__chip--active::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--c-red);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}
.livebar__chip--idle {
  opacity: 0.6;
}

/* ===== matchCard ===== */
.match-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: 8px;
}
.match-card--compact {
  padding: 8px 12px;
}
.match-card__side {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.match-card__side--ao {
  text-align: right;
}
.match-card__name {
  font-weight: 600;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.25;
}
.match-card__dojo {
  font-size: 12px;
  color: var(--c-muted);
}

/* Tatami-Card: farbige Seitenraender AKA rot, AO blau (matcht referee.html) */
.tatami-card .match-card__side--aka {
  border-right: 3px solid var(--c-red, #e63946);
  padding-right: 10px;
}
.tatami-card .match-card__side--ao {
  border-left: 3px solid var(--c-info, #0284c7);
  padding-left: 10px;
}
.tatami-card .match-card__score {
  font-family: var(--f-mono, 'JetBrains Mono', monospace);
  min-width: 80px;
  text-align: center;
}
.match-card__center {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.match-card__score {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.match-card--compact .match-card__score {
  font-size: 18px;
}
.match-card__meta {
  font-size: 12px;
  color: var(--c-muted);
}
.match-card--aka-winner .match-card__side--aka {
  color: var(--c-success, #2e7d32);
}
.match-card--ao-winner .match-card__side--ao {
  color: var(--c-success, #2e7d32);
}

/* ===== bracketTree ===== */
.bracket-tree-wrap {
  overflow-x: auto;
  padding: 16px;
  background: var(--c-bg);
}
.bracket-tree__line {
  fill: none;
  stroke: var(--c-border-strong);
  stroke-width: 2;
}
.match-box__rect {
  fill: var(--c-bg-elev);
  stroke: var(--c-border);
  stroke-width: 1.5;
}
.match-box--waiting .match-box__rect {
  stroke: #bdbdbd;
}
.match-box--running .match-box__rect {
  stroke: #f9a825;
  stroke-width: 2.5;
}
.match-box--finished .match-box__rect {
  stroke: #2e7d32;
}
.match-box--walkover .match-box__rect {
  stroke: #9e9e9e;
  fill: #f5f5f5;
}
.match-box--aborted .match-box__rect {
  stroke: #c62828;
  stroke-dasharray: 4 4;
}
.match-box__aka,
.match-box__ao {
  font-size: 14px;
  fill: var(--c-ink);
  font-family: inherit;
}
.match-box__score {
  font-size: 14px;
  font-weight: 600;
  fill: var(--c-ink);
  font-family: inherit;
}

/* scorePanel — grosser Score + Strafen + Timer + Senshu */
.score-panel {
  display: grid;
  gap: 24px;
  padding: 24px;
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: 12px;
}
.score-panel__top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
}
.score-panel__score {
  font-size: 96px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.score-panel__score--aka {
  color: var(--c-red-deep);
}
.score-panel__score--ao {
  color: var(--c-info);
}
.score-panel__score.is-senshu::after {
  content: 'S';
  font-size: 24px;
  vertical-align: super;
  margin-left: 4px;
  color: var(--c-ink);
}
.score-panel__penalties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
}
.score-panel__pen-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.score-panel__pen-slot {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  background: var(--c-bg);
  color: var(--c-muted);
}
.score-panel__pen-slot.is-active {
  background: #fdd835;
  color: #000;
  border-color: #f9a825;
}
.score-panel__timer {
  font-size: 64px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.score-panel__timer.is-running {
  color: var(--c-success);
}

/* eventLog — chronologische Event-Liste */
.event-log {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--c-bg-elev);
}
.event-log__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.event-log__entry {
  display: flex;
  gap: 12px;
  font-size: 13px;
}
.event-log__ts {
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
}

/* brackets section — Karten-Grid */
.bracket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.bracket-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: 8px;
}
.bracket-card__title {
  margin: 0;
  font-size: 16px;
}
.bracket-card__status {
  align-self: flex-start;
}
.bracket-card__status--muted {
  background: #e5e5e5;
  color: #525252;
}
.bracket-card__status--success {
  background: #dcfce7;
  color: #166534;
}
.bracket-card__status--warning {
  background: #fef3c7;
  color: #92400e;
}
.bracket-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ----- Tatami-Card (Bushido Redesign) ----- */
.tatami-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 12px;
  background: var(--c-bg-elev, #fff);
  border: 1px solid var(--c-border, #e5e5e5);
  border-radius: var(--r-sm, 4px);
  overflow: hidden;
  transition:
    border-color 160ms,
    box-shadow 160ms;
}
.tatami-card::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--c-border, #e5e5e5);
}
.tatami-card--live {
  border-color: var(--c-red, #e63946);
  box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.15);
}
.tatami-card--live::before {
  background: var(--c-red, #e63946);
}

.tatami-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tatami-card__name {
  margin: 0;
  flex: 1;
  font-size: 16px;
}
.tatami-card__type {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--f-mono, monospace);
}
.tatami-card__status {
  margin-left: auto;
}

.tatami-card__cat {
  font-size: 12px;
  color: var(--c-muted, #737373);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tatami-card__body {
  min-height: 60px;
}

.tatami-card__actions {
  display: flex;
  gap: 8px;
  margin: 10px -16px -12px;
  padding: 10px 16px;
  background: #fafafa;
  border-top: 1px solid var(--c-border, #e5e5e5);
}
.tatami-card__actions .btn {
  flex: 1;
}

/* Tatami-Grid: breitere Karten (380 statt 300) */
.tatami-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}
@media (max-width: 760px) {
  .tatami-grid {
    grid-template-columns: 1fr;
  }
}

/* Gruppen-Header fuer Tatami-Gruppierung nach Turnier */
.tatami-groups {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 16px;
}
.tatami-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tatami-group__header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--c-ink, #0a0a0a);
  margin-bottom: 4px;
}
.tatami-group__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.tatami-group__meta {
  font-size: 12px;
  color: var(--c-muted, #737373);
  font-family: var(--f-mono, monospace);
}
.assign-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}
.assign-list__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 6px;
}
.assign-list__text {
  flex: 1;
  font-size: 13px;
}

/* --- Hilfe-Sektion --- */
.hilfe-root {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--s-4, 16px);
  align-items: start;
}
.hilfe-sidebar {
  border-right: 1px solid var(--c-border, #1f2937);
  padding-right: var(--s-3, 12px);
  position: sticky;
  top: var(--s-3, 12px);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.hilfe-search {
  width: 100%;
  padding: var(--s-2, 8px);
  background: var(--c-bg, #0a0a0a);
  color: var(--c-ink, #f5f5f5);
  border: 1px solid var(--c-border, #1f2937);
  margin-bottom: var(--s-3, 12px);
}
.hilfe-toggle {
  display: flex;
  gap: 6px;
  font-size: 12px;
  margin-bottom: var(--s-3, 12px);
  color: var(--c-ink-dim, #94a3b8);
}
.hilfe-tree section + section {
  margin-top: var(--s-3, 12px);
}
.hilfe-tree h3 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--c-ink-dim, #94a3b8);
  margin: 0 0 4px 0;
}
.hilfe-tree ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.hilfe-tree li a {
  display: block;
  padding: 4px 6px;
  text-decoration: none;
  color: var(--c-ink, #f5f5f5);
}
.hilfe-tree li a:hover {
  background: rgba(255, 255, 255, 0.06);
}
.hilfe-stub,
.hilfe-stub-link {
  opacity: 0.6;
  font-style: italic;
}
.hilfe-article {
  max-width: 840px;
  line-height: 1.6;
}
.hilfe-article h1 {
  margin-top: 0;
}
.hilfe-article img {
  max-width: 100%;
  border: 1px solid var(--c-border, #1f2937);
  margin: var(--s-3, 12px) 0;
}
.hilfe-footer {
  margin-top: var(--s-4, 16px);
  padding-top: var(--s-2, 8px);
  border-top: 1px solid var(--c-border, #1f2937);
  font-size: 12px;
  color: var(--c-ink-dim, #94a3b8);
}
.hilfe-version-warn {
  color: var(--c-red, #e63946);
}
.hilfe-error {
  color: var(--c-red, #e63946);
}

@media print {
  .hilfe-sidebar {
    display: none;
  }
  .hilfe-root {
    grid-template-columns: 1fr;
  }
  .hilfe-article {
    max-width: 100%;
  }
}
