@import url("https://fonts.googleapis.com/css2?family=Anton&family=Kalam:wght@400;700&family=Space+Grotesk:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap");

/* DFZ Team-Auslosung – "Kreidetafel": dunkler Schiefer, gedämpfte Kreide, matte Akzente.
   Hart statt weich: 2px-Linien, Schlagschatten ohne Blur, keine Rundungen. */

:root {
  color-scheme: dark;
  --board: #121213;        /* Tafel */
  --board-2: #19191b;      /* Flächen */
  --board-3: #242427;      /* Hover/Karten */
  --chalk: #bfbbb1;        /* Text, gedimmtes Kreide-Grau */
  --chalk-soft: #85827b;   /* Nebentext */
  --line-c: rgba(191, 187, 177, 0.32);
  --amber: #a56f38;        /* einziger Akzent: mattes Kupfer */
  --amber-deep: #3b2a1d;
  --sage: #8a8780;         /* neutrales Grau statt Grün */
  --sage-deep: #26272c;    /* Graphit */
  --danger: #b87868;
  --line: 2px solid var(--line-c);
  --shadow: 6px 6px 0 rgba(0, 0, 0, 0.6);
  --shadow-sm: 3px 3px 0 rgba(0, 0, 0, 0.55);
  --display: "Anton", "Impact", sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
  --hand: "Kalam", "Comic Sans MS", cursive;
  --sans: "Space Grotesk", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--chalk);
  font-family: var(--sans);
  line-height: 1.5;
  background-color: var(--board);
  background-image:
    linear-gradient(rgba(191, 187, 177, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(191, 187, 177, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
}

button, input { font: inherit; }
button { touch-action: manipulation; }
.background-glow { display: none; }

.app-shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 80px;
}

/* ---------- Navigation ---------- */
.tool-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 38px;
  padding-bottom: 12px;
  border-bottom: var(--line);
}

.tool-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--chalk);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  padding: 4px 8px;
  margin: -4px -8px;
}
.tool-nav-link:hover { background: var(--board-3); }
.tool-nav-link:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

.nav-arrow {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

/* ---------- Kopf ---------- */
.hero,
.section-heading,
.drop-zone__heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.hero { margin-bottom: 40px; }

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 14px;
  font-family: var(--display);
  font-size: clamp(3rem, 9vw, 6.2rem);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: 0.005em;
  text-transform: uppercase;
}
h1::after {
  content: "";
  display: block;
  width: 5.2ch;
  max-width: 60%;
  height: 0.16em;
  margin-top: 0.12em;
  background: var(--amber);
}

h2 {
  margin-bottom: 0;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3.4vw, 2.2rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow, .section-kicker {
  margin-bottom: 4px;
  color: var(--chalk-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.section-kicker::before { content: "// "; color: var(--amber); }

.subtitle {
  max-width: 520px;
  margin-bottom: 0;
  color: var(--chalk-soft);
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ---------- Modus-Schalter ---------- */
.mode-controls { display: flex; gap: 18px; flex-shrink: 0; }
.mode-control { min-width: 190px; }
.mode-control > span {
  display: block;
  margin-bottom: 6px;
  color: var(--chalk-soft);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: var(--line);
  background: var(--board-2);
  box-shadow: var(--shadow-sm);
}
.segmented-control label + label { border-left: var(--line); }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span {
  display: block;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.segmented-control span:hover { background: var(--board-3); }
.segmented-control input:checked + span { color: var(--chalk); background: var(--sage-deep); box-shadow: inset 0 -3px 0 var(--amber); }
.segmented-control input:focus-visible + span { outline: 3px solid var(--amber); outline-offset: -3px; }

/* ---------- Panels ---------- */
.panel, .results {
  position: relative;
  padding: 28px;
  border: var(--line);
  background: var(--board-2);
  box-shadow: var(--shadow);
}

.section-heading {
  align-items: flex-end;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: var(--line);
}

/* ---------- Formular ---------- */
.add-player-form { display: flex; gap: 0; box-shadow: var(--shadow-sm); }
input[type="text"] {
  width: min(250px, 45vw);
  padding: 10px 12px;
  border: var(--line);
  border-right: 0;
  border-radius: 0;
  outline: none;
  color: var(--chalk);
  background: var(--board);
  font-family: var(--mono);
  font-size: 0.9rem;
}
input[type="text"]::placeholder { color: #5f5d58; }
input[type="text"]:focus { background: var(--board-3); }

.button {
  min-height: 44px;
  padding: 10px 20px;
  border: var(--line);
  border-radius: 0;
  color: var(--chalk);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}
.button:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
.button--secondary { background: var(--board-3); color: var(--chalk); }
.button--secondary:hover { background: var(--amber); color: var(--board); }
.button--primary {
  min-width: 230px;
  min-height: 56px;
  font-size: 1rem;
  background: var(--amber); color: var(--board);
  box-shadow: var(--shadow);
}
.button--primary:hover { background: #b57d42; transform: translate(-2px, -2px); box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.55); }
.button--primary:active { transform: translate(6px, 6px); box-shadow: 0 0 0 rgba(0, 0, 0, 0.55); }
.button--ghost { background: transparent; box-shadow: var(--shadow-sm); }
.button--ghost:hover { background: var(--board-2); transform: translate(-1px, -1px); }
.button--ghost:active { transform: translate(3px, 3px); box-shadow: none; }

.message { min-height: 1.25em; margin: 12px 0 0; color: var(--danger); font-family: var(--mono); font-size: 0.82rem; font-weight: 700; }
.message--success { color: var(--sage); }

/* ---------- Spieler ---------- */
.player-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 8px; }

.drop-zone {
  min-height: 260px;
  padding: 18px;
  border: 2px dashed var(--line-c);
  background: transparent;
  transition: background 0.12s ease;
}
.drop-zone--participants {
  border-style: solid;
  background: repeating-linear-gradient(-45deg, rgba(165, 111, 56, 0.07) 0 10px, transparent 10px 20px);
}
.drop-zone.is-dragover { background: var(--board-3); }
.drop-zone__heading { align-items: center; }

.count {
  display: grid;
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  place-items: center;
  color: var(--chalk);
  background: var(--board-3);
  font-family: var(--display);
  font-size: 1.25rem;
  line-height: 1;
}
.drop-zone--participants .count { color: var(--board); background: var(--amber); border: var(--line); }

.player-list { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }

.player-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 12px;
  border: var(--line);
  color: var(--chalk);
  background: var(--board-2);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.player-list .player-card:nth-child(odd) { transform: rotate(-1.2deg); }
.player-list .player-card:nth-child(even) { transform: rotate(0.9deg); }
.player-card:hover { background: var(--board-3); transform: translate(-2px, -3px) rotate(0); box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.55); }
.player-card:active { cursor: grabbing; }
.player-card:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
.drop-zone--participants .player-card { background: var(--sage-deep); color: var(--chalk); }
.drop-zone--participants .player-card:hover { background: var(--amber-deep); color: var(--chalk); }

.player-name {
  font-family: var(--hand);
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
}
.player-card__move { font-family: var(--mono); font-size: 0.85rem; font-weight: 700; opacity: 0.7; }
.player-card__delete {
  display: grid;
  width: 24px;
  height: 24px;
  margin: -2px -6px -2px 0;
  padding: 0;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 0;
  color: inherit;
  background: transparent;
  font-family: var(--mono);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.player-card__delete:hover { color: var(--board); background: var(--danger); border-color: var(--danger); }

.empty-state {
  display: none;
  margin: 60px 8px 0;
  color: var(--chalk-soft);
  font-family: var(--mono);
  font-size: 0.82rem;
  text-align: center;
}
.drop-zone:has(.player-list:empty) .empty-state { display: block; }

/* ---------- Aktionen ---------- */
.draw-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 22px;
  padding: 38px 0 34px;
}
.draw-message { flex-basis: 100%; margin: -6px 0 0; text-align: center; }

/* ---------- Ergebnis ---------- */
.round-badge {
  padding: 6px 12px;
  border: var(--line);
  color: var(--chalk);
  background: var(--board-3);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.team-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 0;
  margin-top: 8px;
}
.team-grid--tournament { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 20px; }
.tournament-empty { grid-column: 1 / -1; margin: 24px 0; color: var(--chalk-soft); font-family: var(--mono); text-align: center; }

.team-card {
  min-height: 190px;
  padding: 22px 24px 26px;
  border: var(--line);
  box-shadow: var(--shadow-sm);
}
.team-card--one { color: var(--chalk); background: var(--sage-deep); }
.team-card--two { color: var(--chalk); background: var(--amber-deep); }
.team-card--tournament:nth-child(4n + 1) { color: var(--chalk); background: var(--sage-deep); }
.team-card--tournament:nth-child(4n + 2) { color: var(--chalk); background: var(--amber-deep); }
.team-card--tournament:nth-child(4n + 3) { color: var(--chalk); background: #2d2a33; }
.team-card--tournament:nth-child(4n + 4) { color: var(--chalk); background: #2f2b26; }

.team-label {
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid currentColor;
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.team-members { margin: 0; padding: 0; list-style: none; }
.team-members > li { margin-bottom: 2px; }
.team-members .player-name { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.25; }
.team-members > .team-placeholder { font-family: var(--mono); font-size: 1.4rem; opacity: 0.5; }

.versus {
  display: grid;
  place-items: center;
  width: 78px;
  align-self: center;
  margin: 0 -14px;
  z-index: 1;
  height: 78px;
  border: var(--line);
  border-radius: 50%;
  color: var(--chalk);
  background: var(--board-3);
  box-shadow: var(--shadow-sm);
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: 0.04em;
  transform: rotate(-8deg);
}

.team-grid.is-new .team-card { animation: stamp-in 0.4s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
.team-grid.is-new .team-card--two,
.team-grid.is-new .team-card--tournament:nth-child(even) { animation-delay: 0.1s; }
.team-grid.is-new .versus { animation: stamp-in 0.4s 0.2s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
@keyframes stamp-in {
  from { opacity: 0; transform: scale(1.18) rotate(-3deg); }
  to { opacity: 1; transform: none; }
}

/* ---------- Verlauf ---------- */
.history-panel { margin-top: 36px; }
.history-list { display: grid; gap: 0; margin-top: 4px; border-top: var(--line); }
.history-entry {
  display: grid;
  grid-template-columns: 110px 1fr 1fr;
  gap: 16px;
  padding: 12px 4px;
  border-bottom: 2px solid var(--line-c);
}
.history-entry:nth-child(odd) { background: rgba(191, 187, 177, 0.035); }
.history-entry p { margin: 0; color: var(--chalk-soft); }
.history-entry strong { color: var(--chalk); font-family: var(--mono); font-size: 0.8rem; text-transform: uppercase; }
.history-entry .player-name { color: var(--chalk); font-size: 1.1rem; }
.history-round { color: var(--chalk) !important; font-family: var(--display); font-size: 1.4rem; text-transform: uppercase; line-height: 1.2; }
.history-empty { margin: 0; color: var(--chalk-soft); font-family: var(--mono); font-size: 0.85rem; padding-top: 14px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

::selection { background: var(--amber); color: var(--board); }

/* ---------- Schmal ---------- */
@media (max-width: 860px) {
  .hero { flex-direction: column; align-items: stretch; }
  .mode-controls { width: 100%; }
  .mode-control { flex: 1; min-width: 0; }
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 28px, 1120px); padding-top: 18px; }
  .section-heading { flex-direction: column; align-items: stretch; }
  .round-badge { align-self: flex-start; }
  .add-player-form { width: 100%; }
  input[type="text"] { flex: 1; width: auto; min-width: 0; }
  .player-columns { grid-template-columns: 1fr; }
  .drop-zone { min-height: 190px; }
  .team-grid { grid-template-columns: 1fr; }
  .versus { justify-self: center; margin: -16px 0; }
  .history-entry { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 480px) {
  .panel, .results { padding: 18px; box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.55); }
  .mode-controls { flex-direction: column; gap: 12px; }
  .draw-actions .button { width: 100%; }
  .draw-actions { gap: 16px; }
  .player-card { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
