:root {
  --bg: #0d1f16;
  --bg-2: #12291d;
  --card: #17342473;
  --card-solid: #163123;
  --line: #24513a;
  --fg: #eaf3ec;
  --fg-dim: #9db3a5;
  --accent: #57c97a;
  --accent-dark: #2f7a48;
  --warn: #e2b13c;
  --bad: #e2685c;
  --radius: 14px;
  --tabh: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior-y: none;
  /* Kein Doppeltipp-Zoom und keine 300-ms-Verzögerung auf iOS. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body { background: radial-gradient(120% 60% at 50% 0%, #16362399 0%, transparent 70%), var(--bg); }

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

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 12px) 16px 12px;
  background: linear-gradient(180deg, #0d1f16f2, #0d1f16d0);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #ffffff10;
}
.topbar h1 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: .2px; flex: 1; }
.topbar-extra { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--fg-dim); }
.icon-btn {
  background: #ffffff12; border: 0; color: var(--fg); width: 32px; height: 32px;
  border-radius: 10px; font-size: 17px; cursor: pointer;
}

/* ---------- Inhalt ---------- */
.view { flex: 1; padding: 16px 16px calc(var(--tabh) + var(--safe-b) + 24px); max-width: 720px; width: 100%; margin: 0 auto; }
.view.full { padding: 0 0 calc(var(--tabh) + var(--safe-b)); max-width: none; }

h2 { font-size: 15px; margin: 22px 0 10px; font-weight: 620; }
h2:first-child { margin-top: 4px; }
p { margin: 8px 0; }
.muted { color: var(--fg-dim); }
a { color: var(--accent); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.center { text-align: center; }

.card {
  background: var(--card-solid); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card.tight { padding: 10px 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { height: 12px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: #ffffff0f; color: var(--fg);
  padding: 11px 16px; border-radius: 12px; font-size: 15px; font-weight: 560;
  cursor: pointer; font-family: inherit;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent-dark); border-color: #3d9a5c; color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: #5a2620; border-color: #7c352d; color: #ffd9d4; }
.btn.block { display: block; width: 100%; }
.btn.small { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: default; }

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

/* ---------- Formulare ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--fg-dim); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 11px; font-size: 16px; font-family: inherit;
  background: #0a1a12; border: 1px solid var(--line); color: var(--fg);
}
input:focus, select:focus { outline: 2px solid var(--accent-dark); outline-offset: 1px; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; background: #0a1a12; border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--fg-dim); padding: 8px 4px;
  border-radius: 8px; font: inherit; font-size: 13.5px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--accent-dark); color: #fff; font-weight: 600; }

/* ---------- Listen ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--card-solid); border: 1px solid var(--line); border-radius: var(--radius);
  color: inherit; text-decoration: none; cursor: pointer; text-align: left; width: 100%; font: inherit;
}
.item .t { font-weight: 570; }
.item .s { font-size: 12.5px; color: var(--fg-dim); }
.badge {
  font-size: 12px; font-weight: 650; padding: 4px 9px; border-radius: 999px;
  background: #ffffff12; white-space: nowrap;
}
.badge.good { background: #1f5c34; color: #b8f0c8; }
.badge.bad { background: #5a2a24; color: #ffcdc6; }

/* ---------- Statistik-Kacheln ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.stats-grid.two { grid-template-columns: repeat(2, 1fr); }
.stat { background: var(--card-solid); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 10px; text-align: center; }
.stat-value { font-size: 22px; font-weight: 680; letter-spacing: -.5px; }
.stat-label { font-size: 11.5px; color: var(--fg-dim); margin-top: 2px; }
.stat-sub { font-size: 11px; color: #6f8a7b; margin-top: 2px; }

.bar { height: 7px; background: #0a1a12; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* ---------- Tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; height: calc(var(--tabh) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #0b1c14f0; backdrop-filter: blur(14px); border-top: 1px solid #ffffff10;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--fg-dim); text-decoration: none; font-size: 10.5px; font-weight: 560;
}
.tab-icon { width: 21px; height: 21px; display: block; }
.tab[aria-current="page"] { color: var(--accent); }

/* ---------- Lochansicht ---------- */
.play { display: flex; flex-direction: column; min-height: calc(100dvh - var(--tabh) - var(--safe-b) - 58px); }
.view.full .play { height: calc(100dvh - var(--tabh) - var(--safe-b) - 58px); }
.hole-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 3px 10px 0;
}
.hole-num { font-size: 20px; font-weight: 700; letter-spacing: -.6px; line-height: 1.15; }
.hole-meta { font-size: 11.5px; color: var(--fg-dim); line-height: 1.3; }
.nav-btn {
  background: #ffffff14; border: 0; color: var(--fg); width: 38px; height: 38px;
  border-radius: 12px; font-size: 19px; cursor: pointer; backdrop-filter: blur(3px);
}
.nav-btn:disabled { opacity: .3; }

.dist-row { display: flex; align-items: flex-end; justify-content: center; gap: 14px; padding: 2px 16px 2px; }
.dist-main { text-align: center; }
.dist-main .v { font-size: 38px; font-weight: 700; line-height: 1; letter-spacing: -1.8px; font-variant-numeric: tabular-nums; }
.dist-main .l { font-size: 10px; color: var(--fg-dim); letter-spacing: .6px; text-transform: uppercase; }
.dist-side { text-align: center; padding-bottom: 5px; }
.dist-side .v { font-size: 20px; font-weight: 620; font-variant-numeric: tabular-nums; }
.dist-side .l { font-size: 9.5px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .5px; }

.gps-line {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11.5px; color: var(--fg-dim); padding: 0 10px 5px; min-height: 16px;
  flex-wrap: wrap;
}
.gps-line .hole-meta { white-space: nowrap; }
.gps-line .gps { display: flex; align-items: center; gap: 6px; min-width: 0; }
.gps-line .gps span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gps-line b { font-size: 13.5px; font-weight: 700; letter-spacing: .2px; }
.gps-line .rec { white-space: nowrap; }
.gps-line .rec b { color: var(--accent); }
.gps-line .sel { white-space: nowrap; }
.gps-line .sel b { color: #7fd0ff; }
.gps-line .delta { font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7f73; }
.dot.good { background: #4dd07a; }
.dot.ok { background: var(--warn); }
.dot.poor { background: var(--bad); }

/* Die Karte ist der Bildschirm. Alles andere liegt durchscheinend darüber;
   die Lochansicht bekommt die Höhe der Leisten als Rand und passt die Bahn in
   das freie Rechteck dazwischen ein. */
.map-wrap {
  position: relative; flex: 1; min-width: 0; min-height: 240px;
  overflow: hidden; border-top: 1px solid #ffffff10;
  --kopf-h: 130px; --fuss-h: 200px;
}
.ueber { position: absolute; left: 0; right: 0; z-index: 3; }
.ueber.kopf {
  top: 0; padding-bottom: 4px;
  background: linear-gradient(#070d09e8 62%, #070d09b0 86%, transparent);
}
.ueber.fuss {
  bottom: 0; padding-top: 6px;
  background: linear-gradient(transparent, #070d09b0 16%, #070d09e8 40%);
}

/* Schlägerspalten: über der Karte, an den Rändern, durchscheinend.
   Dort ist die Lochansicht ohnehin abgedunkelt — die Bahn in der Mitte
   bleibt frei. */
.club-col {
  position: absolute; z-index: 2;
  top: calc(var(--kopf-h) + 42px); bottom: calc(var(--fuss-h) + 6px);
  display: flex; flex-direction: column; gap: 4px; width: 60px;
}
.club-col.links { left: 5px; }
.club-col.rechts { right: 5px; }
.club {
  flex: 1; min-height: 24px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 0;
  border: 1px solid #ffffff1f; border-radius: 9px; background: #08140dab;
  backdrop-filter: blur(3px);
  color: #ffffffc4; font: inherit; cursor: pointer; padding: 2px;
}
.club .n { font-size: 12px; font-weight: 650; line-height: 1.1; }
.club .d { font-size: 10px; opacity: .72; font-variant-numeric: tabular-nums; line-height: 1.1; }
.club[aria-pressed="true"] { background: #2f6039e0; border-color: #6cc07a; color: #fff; }
/* Der empfohlene Schläger ist die einzige Stelle, die sich vordrängen darf. */
.club.suggest { border-color: #6cc07a; background: #0b2416c9; color: #fff; }
.club.suggest .d { opacity: 1; color: #8ed474; }
/* Über dem Luftbild braucht die Schrift eine Kante, sonst verschwindet sie. */
.club .n, .club .d { text-shadow: 0 1px 2px rgba(0, 0, 0, .75); }
/* Die Rasterfassung im Profil bleibt undurchsichtig. */
.club-grid .club { background: #ffffff08; border-color: var(--line); color: var(--fg-dim); backdrop-filter: none; }
.club-grid .club .n, .club-grid .club .d { text-shadow: none; }
.club-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.club-grid .club { min-height: 42px; }
/* Auf der Karte zieht der Finger die Zielmarke — er darf dabei nicht scrollen. */
#holemap { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.map-zoom {
  position: absolute; top: calc(var(--kopf-h) + 6px); left: 8px; z-index: 2;
  border: 1px solid #ffffff33; border-radius: 8px; background: #0b1c14c0; color: var(--fg);
  font: inherit; font-size: 11px; padding: 4px 8px; cursor: pointer; backdrop-filter: blur(4px);
}
.map-toggle {
  position: absolute; top: calc(var(--kopf-h) + 6px); right: 8px; z-index: 2;
  border: 1px solid #ffffff33; border-radius: 8px; background: #0b1c14c0; color: var(--fg);
  font: inherit; font-size: 11px; padding: 4px 8px; cursor: pointer; backdrop-filter: blur(4px);
}
.map-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.map-toggle:disabled { opacity: .6; cursor: default; }
/* Fehlgeschlagen: der Knopf bleibt bedienbar — Tippen versucht es erneut. */
.map-toggle.fehler { color: var(--fg-dim); border-style: dashed; }
.map-toggle.fehler::after { content: ' ↻'; }
/* Von den Seitenregeln gesperrt: sichtbar, aber ohne falsches Versprechen */
.map-toggle.gesperrt { color: var(--fg-dim); border-style: dotted; }
.map-toggle.gesperrt::after { content: ' ✕'; }

.map-actions { display: flex; gap: 6px; padding: 0 10px 6px; }
.map-actions .btn {
  flex: 1; padding: 7px 4px; font-size: 12.5px; white-space: nowrap;
  background: #08140dab; border-color: #ffffff1f; backdrop-filter: blur(3px);
}
.map-actions .btn[aria-pressed="true"] { background: var(--accent-dark); border-color: #3d9a5c; color: #fff; }

.score-bar { padding: 0 10px calc(var(--safe-b) + 8px); display: flex; flex-direction: column; gap: 6px; }
.steppers { display: flex; gap: 10px; }
.steppers .stepper { flex: 1; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 42px; height: 38px; border-radius: 12px; border: 1px solid #ffffff1f;
  background: #08140dab; color: var(--fg); font-size: 22px; cursor: pointer; line-height: 1;
  flex: 0 0 auto; backdrop-filter: blur(3px);
}
.stepper .grow { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0 5px; }
.stepper .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stepper .cap { font-size: 10px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .5px; line-height: 1.3; }
.stepper .cap.name { flex-basis: 100%; text-align: center; }

.chips { display: flex; gap: 6px; }
.chip {
  flex: 1; padding: 6px 3px; border-radius: 10px; border: 1px solid #ffffff1f;
  background: #08140d8f; color: #ffffffc4; font: inherit; font-size: 12px; cursor: pointer;
  backdrop-filter: blur(3px);
}
.chip[aria-pressed="true"] { background: var(--accent-dark); border-color: #3d9a5c; color: #fff; font-weight: 600; }
.chip.schmal { flex: 0 0 46px; letter-spacing: 1px; }
/* Diese Reihe darf nie zweizeilig werden: jede Zeile hier fehlt der Bahn.
   Deshalb bricht keine Beschriftung um, und auf sehr schmalen Geräten rücken
   Schrift und Polster zusammen, statt die Reihe wachsen zu lassen. */
.chips .chip { white-space: nowrap; }
@media (max-width: 379px) {
  .chips .chip { font-size: 11px; padding-left: 2px; padding-right: 2px; }
  .chip.schmal { flex: 0 0 34px; }
}

/* ---------- Scorecard ---------- */
.card-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.score { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.score th, table.score td { padding: 7px 5px; text-align: center; border-bottom: 1px solid #ffffff10; white-space: nowrap; }
table.score th { color: var(--fg-dim); font-weight: 560; font-size: 11.5px; }
table.score td.h { text-align: left; color: var(--fg-dim); font-size: 12px; }
table.score tr.sum td { font-weight: 700; background: #ffffff08; }
.sc { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 6px; font-weight: 620; }
.sc.eagle { background: #b8860020; color: #ffd76e; box-shadow: inset 0 0 0 2px #ffd76e; border-radius: 50%; }
.sc.birdie { background: #1f5c3430; color: #7ef0a2; box-shadow: inset 0 0 0 1.5px #7ef0a2; border-radius: 50%; }
.sc.bogey { box-shadow: inset 0 0 0 1.5px #9db3a5; }
.sc.double { box-shadow: inset 0 0 0 1.5px var(--bad); color: #ffb4ab; }

/* ---------- Diagramm ---------- */
.chart { width: 100%; height: 150px; display: block; }

/* ---------- Modal ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 100; background: #000000a8;
  display: flex; align-items: flex-end; justify-content: center; padding: 12px;
}
.modal {
  background: var(--card-solid); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px; width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  padding-bottom: calc(18px + var(--safe-b));
}
.modal-title { font-size: 17px; margin: 0 0 12px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
@media (min-width: 560px) { .modal-wrap { align-items: center; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translate(-50%, 20px);
  bottom: calc(var(--tabh) + var(--safe-b) + 14px); z-index: 200;
  background: #08150ee8; border: 1px solid var(--line); color: var(--fg);
  padding: 10px 16px; border-radius: 999px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: .22s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: #7c352d; }

.empty { text-align: center; color: var(--fg-dim); padding: 40px 20px; }
.empty .big { font-size: 34px; margin-bottom: 10px; opacity: .5; }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.kv { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; border-bottom: 1px solid #ffffff08; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--fg-dim); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Sicherungstext zum Kopieren/Einfügen, wenn kein Dateidialog geht */
.backup-text {
  width: 100%; margin-top: 8px; font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #ffffff0d; color: var(--fg); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px; resize: vertical;
}

/* Spielerwechsel im Profil */
.profile-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.profile {
  border: 1px solid var(--line); border-radius: 999px; background: #ffffff08;
  color: var(--fg-dim); font: inherit; font-size: 13px; padding: 7px 14px; cursor: pointer;
}
.profile.aktiv { background: var(--accent-dark); border-color: #4bb06c; color: #fff; font-weight: 650; }
.profile.neu { border-style: dashed; }
.btn.danger-text { color: #e8776b; border-color: transparent; background: none; padding-left: 0; }

/* Hinweis, wenn die Ortung dauerhaft nicht geht — mit dem Ausweg gleich daneben */
/* Muss vor allen display-Regeln stehen: sonst gewinnt ein eigenes `display`
   gegen die Browser-Regel für [hidden], und ein verstecktes Element belegt
   weiter Platz — das hat schon einmal die Karte kleiner gemacht. */
[hidden] { display: none !important; }

.ortung-hinweis {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 10px 6px; padding: 9px 11px;
  border: 1px solid #b8862f66; border-radius: 12px; background: #b8862f1a;
  font-size: 11.5px; line-height: 1.35; color: var(--fg);
}
.ortung-hinweis .txt { flex: 1; min-width: 0; }
.ortung-hinweis .btn { flex: 0 0 auto; white-space: nowrap; }

/* Erinnerung an die Datensicherung — die Runden liegen nur auf dem Gerät. */
.sicherung-hinweis {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  padding: 9px 12px; border-radius: 12px;
  border: 1px solid #b8862f66; background: #b8862f1a; font-size: 12.5px;
}
.sicherung-hinweis .txt { flex: 1; min-width: 0; }
.sicherung-hinweis .btn { flex: 0 0 auto; }

/* Notfall-Adresse: muss auch auf einem schmalen Handy vollständig lesbar sein
   und darf nicht seitlich aus dem Bild laufen. */
.notfall {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  padding: 8px 10px;
  user-select: all;
  -webkit-user-select: all;
}

/* Gestrichenes Loch: der Wert zählt, ausgespielt wurde es aber nicht.
   Ein Punktrand darunter sagt das, ohne die Zahl schlechter lesbar zu machen. */
.sc.gestrichen { border-bottom: 2px dotted currentColor; }
/* Der Streichen-Knopf trägt zwei Wörter und eine Zahl. Bräche er auf zwei
   Zeilen um, würde die ganze Reihe höher — und genau diese Höhe fehlt der
   Karte. Er bleibt deshalb einzeilig und etwas kleiner gesetzt. */
.chip.streichen { flex: 0 1 auto; padding-left: 10px; padding-right: 10px; }
.chip.streichen[aria-pressed="true"] {
  background: #7a4a1e;
  border-color: #c98a3e;
  color: #ffe6c7;
}

/* Die Lochzeile ist antippbar (Handicap korrigieren). Das muss man sehen,
   ohne dass sie wie ein Knopf aussieht und von der Karte ablenkt. */
.hole-meta.tippbar { cursor: pointer; text-decoration: underline dotted #ffffff40; text-underline-offset: 3px; }
