:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --text: #2b2620;
  --muted: #7a7266;
  --primary: #1f6f4f;
  --primary-dark: #16523a;
  --accent: #c1440e;
  --accent-dark: #973309;
  --danger: #b3261e;
  --border: #e4ddcf;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(43, 38, 32, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: 96px; /* Platz für Rückgängig-Button */
}

.hidden { display: none !important; }

h1, h2, h3 { margin: 0 0 8px; }

.muted { color: var(--muted); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ---------- Buttons ---------- */

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-block { width: 100%; }
.btn-small { padding: 8px 12px; font-size: 0.85rem; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: #e8e2d4; color: var(--text); }

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

.btn-special {
  background: var(--accent);
  color: white;
  flex: 1;
  padding: 16px 10px;
  line-height: 1.4;
  border-radius: 12px;
}
.btn-special:hover { background: var(--accent-dark); }
.btn-sub { font-weight: 400; font-size: 0.78rem; opacity: 0.9; }

.btn-modal {
  background: #f0ece1;
  color: var(--text);
  padding: 16px;
  font-size: 1.05rem;
  border-radius: 12px;
}
.btn-modal:hover { background: #e4ddcb; }

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

/* ---------- Login ---------- */

.view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-box input {
  width: 100%;
  padding: 12px;
  margin: 16px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

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

/* ---------- Header / Nav ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
}
.app-header h1 { font-size: 1.2rem; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.tab-btn {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.view { padding: 0 16px 20px; max-width: 720px; margin: 0 auto; }

.section-title { margin: 18px 0 10px; font-size: 1.05rem; }
.subsection-title { margin: 22px 0 10px; font-size: 0.95rem; color: var(--muted); }

.center-box { text-align: center; }

/* ---------- Runde / Strafen ---------- */

.round-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.round-bar-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.special-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.hint-text { margin-top: -4px; margin-bottom: 14px; font-size: 0.85rem; }

.end-of-evening {
  margin-top: 24px;
}

.end-of-evening-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.end-of-evening-buttons .btn {
  flex: 1;
  min-width: 160px;
  padding: 14px 12px;
  line-height: 1.4;
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  cursor: pointer;
  border: 2px solid transparent;
}
.archive-item:active { border-color: var(--primary); }

.archive-item-date { font-weight: 600; }
.archive-item-total { color: var(--muted); }

.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.member-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px;
  text-align: center;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.1s ease;
}

.member-card:active { border-color: var(--primary); }

.member-card .member-card-name { margin-bottom: 2px; }

.member-card-actions {
  margin-top: 12px;
}

.member-card-actions.hidden { display: none; }

.quick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.btn-quick-custom {
  width: 100%;
  margin-top: 6px;
}

.custom-penalty-form {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}

.custom-penalty-form.hidden { display: none; }

.custom-penalty-input {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  text-align: right;
}

.custom-penalty-confirm,
.custom-penalty-cancel {
  padding: 10px 14px;
  flex-shrink: 0;
}

.btn-quick {
  background: #f0ece1;
  color: var(--text);
  padding: 10px 4px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 8px;
  line-height: 1.3;
}
.btn-quick:hover { background: #e4ddcb; }
.btn-quick { font-size: 0.85rem; padding: 12px 6px; }

/* ---------- Anwesenheit ---------- */

.attendance-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.attendance-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px;
  cursor: pointer;
  border: 2px solid transparent;
}

.attendance-item.checked {
  border-color: var(--primary);
  background: #e7f3ec;
}

.attendance-item input { width: 18px; height: 18px; pointer-events: none; }

.attendance-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Statistik ---------- */

.podium {
  background: linear-gradient(135deg, #f4d35e, #ee964b);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.podium-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 700;
}

.podium-row .podium-medal { font-size: 1.1rem; }
.podium-row .podium-count { font-weight: 400; opacity: 0.85; font-size: 0.85rem; }

.table-wrap { overflow-x: auto; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.stats-table th, .stats-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.stats-table th { background: #efe9db; font-size: 0.85rem; }
.stats-table tfoot td { font-weight: 700; border-bottom: none; }

.stats-table td.stats-action-cell {
  white-space: normal;
  min-width: 150px;
}
.stats-table td.stats-action-cell .custom-penalty-form {
  margin-top: 0;
}

/* ---------- Mitglieder ---------- */

.add-member-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.add-member-form input {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.members-list { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Einstellungen ---------- */

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
}

.settings-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  white-space: nowrap;
}

.settings-input-wrap input {
  width: 90px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  text-align: right;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
}

.member-row input.member-name-input {
  border: none;
  background: transparent;
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.member-row input.member-name-input:focus {
  outline: 1px solid var(--primary);
  border-radius: 6px;
}

.member-row-actions { display: flex; gap: 6px; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 32, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 420px;
  border-radius: 18px 18px 0 0;
  padding: 24px;
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius); }
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.modal-werfer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 16px;
  max-height: 40vh;
  overflow-y: auto;
}

.modal-werfer-list .btn { text-align: left; }

/* ---------- Rückgängig ---------- */

.fab-undo {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 14px 26px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 40;
}
.fab-undo:active { transform: translateX(-50%) scale(0.96); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  z-index: 60;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}

.toast.toast-error { background: var(--danger); }
