:root {
  --bg: #f4f1ec;
  --card: #ffffff;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --primary: #0f3d2e;
  --primary-hover: #145a44;
  --accent: #b71c1c;
  --border: #e3ddd3;
  --success: #2e7d32;
  --warn: #c0792b;
  --danger: #b71c1c;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

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

#app { min-height: 100vh; display: flex; flex-direction: column; }

#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--primary); color: #fff;
  position: sticky; top: 0; z-index: 50;
  padding-top: max(10px, env(safe-area-inset-top));
}
#topbar h1 { font-size: 18px; font-weight: 600; margin: 0; flex: 1; }
.hamburger {
  background: transparent; border: 0; color: #fff; font-size: 22px;
  width: 40px; height: 40px; border-radius: 8px; cursor: pointer;
}
.hamburger:hover { background: rgba(255,255,255,.1); }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px;
}
.user-chip img, .user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  background: rgba(255,255,255,.15); display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700;
}

#sidenav {
  position: fixed; top: 0; bottom: 0; left: -260px;
  width: 240px; background: #fff; padding: 60px 12px 20px;
  box-shadow: 2px 0 12px rgba(0,0,0,.1);
  z-index: 40; transition: left .25s ease;
  display: flex; flex-direction: column; gap: 4px;
  padding-top: calc(60px + env(safe-area-inset-top));
}
#sidenav.open { left: 0; }
.navlink {
  text-align: left; padding: 12px 14px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; font-size: 15px;
  color: var(--text); width: 100%;
}
.navlink:hover { background: var(--bg); }
.navlink.active { background: var(--primary); color: #fff; }
.navlink.danger { color: var(--danger); margin-top: auto; }

#sidenav.open + main::before {
  content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 30;
}

@media (min-width: 900px) {
  #sidenav {
    position: static; left: 0; box-shadow: none; width: 220px;
    padding: 14px;
  }
  #app { flex-direction: row; }
  #app > #topbar { display: none; }
  .hamburger { display: none; }
  main#view { flex: 1; }
}

main#view {
  flex: 1; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 1100px; width: 100%; margin: 0 auto;
}

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
  border: 1px solid var(--border);
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 16px; background: #fff;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,61,46,.15);
}
.field { margin-bottom: 12px; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 140px; }

button.btn, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border: 0; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: inherit; min-height: 42px;
}
button.btn:hover, .btn:hover { background: var(--primary-hover); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.warn { background: var(--warn); }
.btn.small { padding: 6px 10px; font-size: 13px; min-height: 32px; }
.btn.full { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.list { list-style: none; padding: 0; margin: 0; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--bg); color: var(--text);
}
.badge.green { background: #d6efd6; color: var(--success); }
.badge.amber { background: #f6e3c4; color: var(--warn); }
.badge.red { background: #f5cccc; color: var(--danger); }
.badge.blue { background: #cfe0f5; color: #1e3a8a; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab {
  padding: 10px 14px; border: 0; background: transparent; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
table.data th, table.data td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: linear-gradient(135deg, var(--primary), #1c5a45);
}
.auth-card {
  background: #fff; border-radius: 16px; padding: 24px;
  width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-card h1 {
  margin: 0 0 4px; font-size: 28px; color: var(--primary);
  display: flex; align-items: center; gap: 10px;
}
.auth-card .subtitle { color: var(--muted); margin: 0 0 20px; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.large { width: 80px; height: 80px; font-size: 28px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 100;
}
.modal {
  background: #fff; border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  padding: 20px;
}
.modal h3 { margin: 0 0 14px; }

#toastRoot {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1c1c1c; color: #fff; padding: 10px 16px; border-radius: 8px;
  box-shadow: var(--shadow); animation: pop .25s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.gameday-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px; border-radius: var(--radius); background: #fff;
  border: 1px solid var(--border); margin-bottom: 10px; cursor: pointer;
}
.gameday-card:hover { border-color: var(--primary); }
.gameday-card .top { display: flex; align-items: center; gap: 8px; }
.gameday-card .top h3 { margin: 0; font-size: 16px; flex: 1; }

.player-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px; background: var(--bg);
  border-radius: 999px; font-size: 13px;
  margin: 2px;
}
.player-chip .avatar { width: 24px; height: 24px; font-size: 11px; }

.checkbox-row {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px;
}
.checkbox-row label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--text); margin: 0;
  cursor: pointer; padding: 6px 0;
}

.player-pick {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px;
  margin-bottom: 8px;
}
.player-pick button {
  padding: 10px; border: 1px solid var(--border); background: #fff;
  border-radius: 8px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.player-pick button.selected {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

.score-preview {
  background: var(--bg); border-radius: 8px; padding: 10px;
  font-size: 14px; margin: 8px 0;
}
.score-preview.win { background: #d6efd6; color: var(--success); }
.score-preview.lose { background: #f5cccc; color: var(--danger); }

.rank-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 8px; background: var(--bg);
  margin-bottom: 6px;
}
.rank-row .rank-num {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.rank-row.gold .rank-num { background: #d4a017; }
.rank-row.silver .rank-num { background: #9e9e9e; }
.rank-row.bronze .rank-num { background: #b87333; }

.hidden { display: none !important; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex.between { justify-content: space-between; }
.spacer { flex: 1; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }

.spitzen-selector {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.spitzen-selector button {
  width: 38px; height: 38px; border: 1px solid var(--border);
  background: #fff; border-radius: 6px; cursor: pointer; font-weight: 600;
}
.spitzen-selector button.selected {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

.round-list { max-height: 400px; overflow-y: auto; }

.live-indicator {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--success); font-weight: 600;
}
.live-indicator::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
