:root {
  --green: #1b5e20;
  --green-light: #2e7d32;
  --green-pale: #e8f5e9;
  --bg: #f4f6f4;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e2e6e2;
  --red: #c62828;
  --amber: #ef6c00;
  --shadow: 0 2px 10px rgba(0,0,0,.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.view { min-height: 100vh; }

/* ===== Auth ===== */
#auth-view {
  display: flex; align-items: center; justify-content: center;
  padding: 24px; min-height: 100vh;
  background: linear-gradient(160deg, var(--green) 0%, var(--green-light) 100%);
}
.auth-card {
  background: var(--card); border-radius: 20px; padding: 32px 24px;
  width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.2);
  text-align: center;
}
.auth-card .logo { font-size: 48px; }
.auth-card h1 { margin: 8px 0 4px; font-size: 26px; color: var(--green); }
.subtitle { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.auth-card input {
  width: 100%; padding: 14px; margin-bottom: 12px; border: 1px solid var(--border);
  border-radius: 12px; font-size: 16px;
}
.msg { min-height: 20px; font-size: 14px; margin: 10px 0 0; }
.msg.error { color: var(--red); }
.msg.ok { color: var(--green-light); }

/* ===== Buttons ===== */
button { font-family: inherit; cursor: pointer; border: none; }
.primary {
  width: 100%; padding: 14px; background: var(--green); color: #fff;
  border-radius: 12px; font-size: 16px; font-weight: 600; margin-bottom: 8px;
}
.primary:active { background: var(--green-light); }
.ghost {
  width: 100%; padding: 12px; background: transparent; color: var(--green);
  border-radius: 12px; font-size: 15px; font-weight: 500;
}
.icon-btn { background: transparent; color: #fff; font-size: 20px; padding: 6px 10px; }

/* ===== Topbar / Tabbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top));
  background: var(--green); color: #fff;
}
.brand { font-weight: 700; font-size: 17px; }
#main { padding: 16px; padding-bottom: 90px; max-width: 640px; margin: 0 auto; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: transparent; padding: 10px 4px 8px; font-size: 22px;
  color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab span { font-size: 11px; }
.tab.active { color: var(--green); }

/* ===== Cards & layout ===== */
.card {
  background: var(--card); border-radius: 16px; padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.section-title h2 { margin: 0; font-size: 20px; color: var(--green); }
.add-btn {
  background: var(--green); color: #fff; border-radius: 50%; width: 40px; height: 40px;
  font-size: 24px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 16px; font-family: inherit; background: #fff;
}
.muted { color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* Round list item */
.round-item { display: flex; align-items: center; justify-content: space-between; }
.round-item .date { font-weight: 600; }
.round-item .course { color: var(--muted); font-size: 13px; }
.score-badge {
  font-weight: 700; font-size: 18px; padding: 6px 12px; border-radius: 10px;
  background: var(--green-pale); color: var(--green);
}
.score-badge.over { background: #fdecea; color: var(--red); }
.score-badge.even { background: #eef2ff; color: #3730a3; }

/* Hole entry grid */
.hole-card { border-left: 4px solid var(--green); }
.hole-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.hole-head .no { font-weight: 700; font-size: 16px; }
.par-pill { background: var(--green-pale); color: var(--green); padding: 2px 10px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.toggle-group { display: flex; gap: 8px; }
.toggle-group button {
  flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; font-size: 14px; color: var(--muted);
}
.toggle-group button.on { background: var(--green); color: #fff; border-color: var(--green); }
.toggle-group button.off-on { background: var(--red); color: #fff; border-color: var(--red); }

/* Stats */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: var(--card); border-radius: 16px; padding: 16px; box-shadow: var(--shadow);
  text-align: center;
}
.stat .val { font-size: 26px; font-weight: 700; color: var(--green); }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.warn .val { color: var(--amber); }
.insight { background: var(--green-pale); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; font-size: 14px; line-height: 1.5; }
.insight b { color: var(--green); }

.sticky-save {
  position: fixed; bottom: 76px; left: 16px; right: 16px; max-width: 608px; margin: 0 auto;
  z-index: 9;
}
.link-btn { background: none; color: var(--green); font-size: 14px; padding: 4px; }

/* Abschlagstafel-Bilder */
.tafel { margin: 8px 0 2px; }
.tafel summary { cursor: pointer; color: var(--green); font-size: 14px; font-weight: 500; padding: 6px 0; list-style: none; }
.tafel summary::-webkit-details-marker { display: none; }
.tafel summary::before { content: "▸ "; }
.tafel[open] summary::before { content: "▾ "; }
.tafel img { width: 100%; border-radius: 10px; margin-top: 8px; border: 1px solid var(--border); background: #fff; }
/* Live-Modus */
.play-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.play-score { font-size: 14px; color: var(--muted); }
.play-score b { color: var(--green); font-size: 16px; }
.play-progress { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.play-progress > div { height: 100%; background: var(--green); transition: width .2s; }
.play-hole { text-align: center; }
.play-hole-head { display: flex; align-items: center; justify-content: center; gap: 10px; }
.play-no { font-size: 22px; font-weight: 700; color: var(--green); }
.play-name { font-size: 16px; margin-top: 6px; font-weight: 500; }
.stepper { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stepper:last-child { border-bottom: none; }
.stepper-lbl { font-size: 16px; font-weight: 500; }
.stepper-ctrl { display: flex; align-items: center; gap: 16px; }
.step {
  width: 48px; height: 48px; border-radius: 50%; font-size: 26px; line-height: 1;
  background: var(--green-pale); color: var(--green); font-weight: 700;
}
.step:active { background: var(--green); color: #fff; }
.stepper-val { min-width: 42px; text-align: center; font-size: 24px; font-weight: 700; }
.play-nav {
  display: flex; gap: 10px; align-items: stretch;
  margin-top: 8px; padding-bottom: 8px;
}
.play-nav button { width: auto; margin: 0; }
.play-nav .ghost { flex: 1; padding: 14px 8px; font-size: 14px; background: var(--green-pale); }
.play-nav .primary { flex: 1.5; padding: 16px; font-size: 17px; }
.play-nav button:disabled { opacity: .4; }

.hcap-badge { font-size: 11px; font-weight: 600; color: var(--green); background: var(--green-pale); padding: 2px 8px; border-radius: 20px; margin-left: 6px; }

/* Live-Scoreboard */
.mhs-grid { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 10px; }
.mhs-cell { width: 30px; height: 34px; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; line-height: 1.1; border: 1px solid var(--border); }
.mhs-cell .mhs-h { color: var(--muted); font-size: 9px; }
.mhs-cell .mhs-p { font-weight: 700; font-size: 13px; }
.mhs-cell.g3 { background: #e8f5e9; border-color: #a5d6a7; color: var(--green); }
.mhs-cell.g2 { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.mhs-cell.g1 { background: #fff7ed; border-color: #fdba74; color: var(--amber); }
.mhs-cell.g0 { background: #fdecea; border-color: #f5b1aa; color: var(--red); }
.hole-desc { font-size: 14px; line-height: 1.5; color: var(--muted); margin: 10px 2px 0; text-align: left; }
textarea { resize: vertical; }

.tafel-link { display: block; text-align: center; margin: 10px 0 2px; }
.tafel-img {
  display: block; height: 190px; width: auto; max-width: 100%;
  margin: 0 auto; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; box-shadow: var(--shadow); object-fit: contain;
}
.danger { color: var(--red); }
