:root {
  --color-bg: #f1f2f4;
  --color-surface: #ffffff;
  --color-text: #1c1e22;
  --color-text-muted: #6b7280;
  --color-border: #dfe1e5;

  /* Neongruen: als Flaeche sehr hell/knallig (fuer Buttons/Badges mit
     dunklem Text), als "-strong"-Variante abgedunkelt fuer lesbaren Text
     und Linien auf hellem Grund. */
  --color-green: #39ff14;
  --color-green-strong: #16a34a;

  /* Amber/Orange als zweite Akzentfarbe, gleiches Prinzip. */
  --color-amber: #ffb700;
  --color-amber-strong: #b45309;

  --color-on-accent: #0b1210;
  --color-focus: #2563eb;
  --color-danger: #d1293d;

  --shadow-card: 0 1px 2px rgba(16, 20, 30, 0.04), 0 8px 24px rgba(16, 20, 30, 0.06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #17181b;
    --color-surface: #202226;
    --color-text: #eef0f2;
    --color-text-muted: #9aa0a8;
    --color-border: #2d2f34;

    --color-green: #4dff2e;
    --color-green-strong: #34d058;

    --color-amber: #ffc233;
    --color-amber-strong: #fbbf24;

    --color-on-accent: #0b1210;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-green);
  color: var(--color-on-accent);
  padding: 0.75rem 1.25rem;
  z-index: 100;
  border-radius: 0 0 8px 0;
  font-weight: 700;
}

.skip-link:focus {
  left: 0;
}

a {
  color: var(--color-green-strong);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.app-header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem 0.6rem;
}

.app-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--color-text);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.app-header__logo {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.app-header h1 {
  margin: 0.6rem 0 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.app-header__subtitle {
  margin: 0.15rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.app-header__accent {
  width: 48px;
  height: 3px;
  margin: 0.6rem 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-green), var(--color-amber));
}

.app-nav {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.app-nav .btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.75rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

/* Buttons */
.btn {
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-green);
  color: var(--color-on-accent);
}

.btn--primary:hover {
  filter: brightness(0.92);
}

.btn--secondary {
  background: var(--color-amber);
  color: var(--color-on-accent);
}

.btn--secondary:hover {
  filter: brightness(0.92);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  font-weight: 600;
}

.btn--ghost:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.btn--danger {
  background: var(--color-danger);
  color: #fff;
}

.btn--danger:hover {
  filter: brightness(0.92);
}

.btn--small {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  border-radius: 6px;
}

/* Formulare */
.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form label {
  font-weight: 600;
  font-size: 0.9rem;
}

.form input[type="number"],
.form input[type="text"] {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1rem;
}

.hint-text {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.starting-player-legend {
  margin: 0.75rem 0 0;
  text-align: left;
}

.error-text {
  color: var(--color-danger);
  font-weight: 600;
}

/* Modus-Karten auf der Startseite */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.mode-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-green);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.mode-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(16, 20, 30, 0.06), 0 12px 28px rgba(16, 20, 30, 0.1);
}

.mode-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
}

.mode-card__examples {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

/* Spielerauswahl (Checkbox-Chips) */
.player-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 2px solid var(--color-border);
  background: var(--color-bg);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
}

.player-chip input {
  accent-color: var(--color-green-strong);
}

.player-chip--checked {
  border-color: var(--color-green-strong);
  background: color-mix(in srgb, var(--color-green) 15%, var(--color-bg));
}

/* Sticky Scoreboard */
.scoreboard {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-bg);
  padding-top: 0.75rem;
  padding-bottom: 0.5rem;
}

.scoreboard-card {
  border-top: 4px solid var(--color-green);
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
}

.standings-table th,
.standings-table td {
  text-align: left;
  padding: 0.6rem 0.4rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
}

.standings-table td:nth-child(3) {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.standings-table th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.standings-table tr.rank-first {
  background: color-mix(in srgb, var(--color-green) 12%, transparent);
}

.standings-table tr.rank-first td {
  font-weight: 700;
}

.standings-table tr.rank-first td:nth-child(2) {
  color: var(--color-green-strong);
  font-size: 1.15rem;
  font-weight: 800;
}

.standings-table tr.rank-first td:nth-child(3) {
  color: var(--color-green-strong);
  font-size: 1.55rem;
}

.standings-table tr.rank-first td:first-child {
  box-shadow: inset 4px 0 0 0 var(--color-green-strong);
  padding-left: 0.6rem;
}

.standings-table .progress-cell {
  min-width: 120px;
}

.mini-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
  margin-top: 0.3rem;
}

.mini-progress__fill {
  height: 100%;
  background: var(--color-amber);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.mini-progress__fill--done {
  background: var(--color-green-strong);
}

/* Gewinner-Banner */
.winner-banner {
  background: var(--color-green);
  color: var(--color-on-accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  box-shadow: var(--shadow-card);
}

/* Rundenerfassung */
.round-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.round-form-field label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.round-form-field input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1.1rem;
  text-align: center;
}

/* Rundenverlauf / Korrektur - immer sichtbar und direkt editierbar */
.rounds-table-wrap {
  overflow-x: auto;
}

.rounds-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.rounds-table th,
.rounds-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.88rem;
}

.rounds-table th:first-child,
.rounds-table td:first-child {
  text-align: left;
  color: var(--color-text-muted);
}

.rounds-table input[type="number"] {
  width: 4.5rem;
  padding: 0.35rem 0.3rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  text-align: center;
  font-size: 0.9rem;
}

.rounds-table__row-actions {
  white-space: nowrap;
}

/* Spielerverwaltung */
.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg);
}

.player-list input[type="text"] {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

/* Verlauf */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
}

.history-item:hover {
  border-color: var(--color-green-strong);
}

.history-item__title {
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.history-item__meta {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge--active {
  background: var(--color-amber);
  color: var(--color-on-accent);
}

.badge--finished {
  background: var(--color-green);
  color: var(--color-on-accent);
}

/* Responsive: Desktop-Layouts ab Tablet-Breite */
@media (min-width: 700px) {
  .two-col {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 1.5rem;
    align-items: start;
  }
}

.section-spacing {
  margin-top: 1.5rem;
}

.app-version {
  position: fixed;
  right: 0.75rem;
  bottom: 0.5rem;
  z-index: 50;
  margin: 0;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  opacity: 0.7;
  pointer-events: none;
}

/* Finger-Chooser */
.chooser-card {
  padding: 0.75rem;
}

.chooser-area {
  position: relative;
  width: 100%;
  height: min(70vh, 700px);
  min-height: 360px;
  background: var(--color-bg);
  border: 1px dashed var(--color-border);
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chooser-hint {
  color: var(--color-text-muted);
  font-size: 1.3rem;
  text-align: center;
  padding: 1rem;
  pointer-events: none;
  max-width: 20rem;
}

.chooser-hint--result {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--color-text);
  font-weight: 700;
  font-size: 1.05rem;
}

.chooser-countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 7rem;
  font-weight: 800;
  color: var(--color-amber);
  pointer-events: none;
  z-index: 5;
}

.finger-circle {
  position: absolute;
  width: 96px;
  height: 96px;
  margin-left: -48px;
  margin-top: -48px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-green) 30%, transparent);
  border: 3px solid var(--color-green-strong);
  transition: width 0.5s ease, height 0.5s ease, margin 0.5s ease,
    background 0.5s ease, border-color 0.5s ease, opacity 0.5s ease;
  pointer-events: none;
}

/* Kurzer "Pop": Kreis erscheint deutlich groesser und schrumpft dann auf die
   Ruhegroesse - bestaetigt sofort sichtbar, dass der Finger erkannt wurde. */
@keyframes finger-pop {
  0% {
    transform: scale(1.7);
    opacity: 0.55;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.finger-circle--pop {
  animation: finger-pop 0.3s ease-out;
}

.finger-circle--selected {
  width: 180px;
  height: 180px;
  margin-left: -90px;
  margin-top: -90px;
  background: var(--color-green);
  border-color: var(--color-on-accent);
  box-shadow: 0 0 50px color-mix(in srgb, var(--color-green) 55%, transparent);
}

.finger-circle--faded {
  opacity: 0;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
}
