:root {
  --bg: #eef2e6;
  --bg2: #e1e9d6;
  --card: #fbfcf7;
  --text: #1c2a1f;
  --muted: #627064;
  --line: #d3dccb;
  --accent: #2c7a44;       /* Rasengrün */
  --accent-text: #f6fbf2;
  --flag: #e0a92e;
  --good: #2c7a44;
  --bad: #c2523b;
  --p0: #e2553d;           /* Ball Spieler 1 */
  --p1: #2d6cdf;           /* Ball Spieler 2 */
  --shadow: 0 10px 30px rgba(30, 60, 30, .14);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101611; --bg2: #172019; --card: #1a241c; --text: #e8efe4; --muted: #98a693;
    --line: #2c3a2e; --accent: #4ca866; --accent-text: #0d140e; --good: #6fc985; --bad: #e57a62;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101611; --bg2: #172019; --card: #1a241c; --text: #e8efe4; --muted: #98a693;
  --line: #2c3a2e; --accent: #4ca866; --accent-text: #0d140e; --good: #6fc985; --bad: #e57a62;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%) fixed, var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.wrap { max-width: 560px; margin: 0 auto; padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none;
  font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 1.4rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.card.small { max-width: 320px; width: calc(100% - 32px); text-align: center; padding: 22px 20px; }
.card.small h2 { font-family: Fraunces, Georgia, serif; margin: 0 0 6px; font-size: 1.45rem; }
.card.small p { color: var(--muted); margin: 0 0 14px; }
.card.small p.tally-line { color: var(--text); font-weight: 600; margin-top: -6px; }

h1 { font-family: Fraunces, Georgia, serif; font-size: 2rem; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 20px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
input {
  flex: 1 1 180px; min-width: 0; font: inherit; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  font: inherit; font-weight: 600; border-radius: 12px; padding: 12px 18px; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  transition: transform .08s ease, background .2s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg2); }
.card.small .btn { width: 100%; margin-top: 4px; }
.card.small .btn.ghost { border: none; color: var(--muted); }

.rules { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
.rules summary { cursor: pointer; font-weight: 600; }
.rules ol { padding-left: 20px; color: var(--muted); line-height: 1.55; }
.rules b { color: var(--text); }

.history { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
.history h2 { font-size: 1rem; margin: 0 0 10px; }
.pf-history { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.pf-history li { display: flex; gap: 10px; font-size: .9rem; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.pf-res { font-weight: 600; width: 6.5em; flex: none; }
.pf-win .pf-res { color: var(--good); } .pf-loss .pf-res { color: var(--bad); } .pf-draw .pf-res { color: var(--muted); }
.pf-opp { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pf-date { color: var(--muted); flex: none; }

/* ---------- Spiel ---------- */
.players { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.player {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); min-width: 0; transition: box-shadow .25s, border-color .25s;
}
.player.right { flex-direction: row-reverse; text-align: right; }
.player.turn { border-color: var(--pc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--pc) 35%, transparent); }
.player.offline .pname { opacity: .5; }
#p0 { --pc: var(--p0); } #p1 { --pc: var(--p1); }
.player .ball { width: 16px; height: 16px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff 0 18%, var(--pc) 60%); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.pname small { font-weight: 500; color: var(--muted); }
.tot { font-size: .82rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tot b { color: var(--text); font-size: .95rem; }
.vs { display: flex; flex-direction: column; align-items: center; line-height: 1.1; min-width: 52px; }
.vs b { font-family: Fraunces, Georgia, serif; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vs small { color: var(--muted); font-size: .68rem; white-space: nowrap; }

.holebar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 2px 8px; font-size: .92rem; }
.holebar #holeInfo b { font-family: Fraunces, Georgia, serif; font-size: 1.05rem; }
.holebar #holeInfo span { color: var(--muted); margin-left: 2px; }
.holebar #holeInfo { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--bg2); color: var(--muted);
  white-space: nowrap; font-variant-numeric: tabular-nums; }

.course-wrap {
  position: relative; margin: 0 auto; aspect-ratio: 9 / 16;
  width: min(100%, calc((100dvh - 250px) * 9 / 16)); min-width: min(100%, 260px);
  border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); background: #cfc8ae;
}
#course { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; }
#course.wait { cursor: default; }

.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  background: rgba(16, 28, 18, .82); color: #fff; font-weight: 700; font-size: 1.1rem; text-align: center;
  padding: 10px 18px; border-radius: 14px; pointer-events: none; max-width: calc(100% - 32px); width: max-content;
  animation: bannerIn .35s cubic-bezier(.2, .9, .3, 1.3); backdrop-filter: blur(3px);
}
.banner small { display: block; font-weight: 500; font-size: .82rem; opacity: .8; }
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -30%) scale(.9); } }

.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 25, 12, .38); backdrop-filter: blur(2px); animation: fade .25s ease;
}
.hint { font-size: .85rem; min-height: 1.2em; margin: 8px 0 0 !important; }

.status { text-align: center; min-height: 1.5em; margin: 12px 0 6px; font-weight: 500; }
.status b { color: var(--accent); }
.status .who0 { color: var(--p0); font-weight: 700; } .status .who1 { color: var(--p1); font-weight: 700; }

/* Scorekarte */
.scorecard { margin-top: 10px; display: grid; gap: 8px; }
.scorecard table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .8rem; font-variant-numeric: tabular-nums;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; table-layout: fixed; }
.scorecard th, .scorecard td { text-align: center; padding: 5px 0; border-bottom: 1px solid var(--line); }
.scorecard tr:last-child td { border-bottom: 0; }
.scorecard th:first-child, .scorecard td:first-child { text-align: left; padding-left: 8px; width: 4.6em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scorecard thead th { color: var(--muted); font-weight: 600; background: var(--bg2); }
.scorecard .par td { color: var(--muted); }
.scorecard .cur { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.scorecard thead .cur { color: var(--accent); }
.scorecard td.under { color: var(--good); font-weight: 700; }
.scorecard td.over { color: var(--bad); }
.scorecard td.sum { font-weight: 700; }
.scorecard .r0 td:first-child { color: var(--p0); font-weight: 600; } .scorecard .r1 td:first-child { color: var(--p1); font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.actions .btn { padding: 10px 14px; font-size: .92rem; }

@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 420px) {
  .card { padding: 18px; }
  h1 { font-size: 1.7rem; }
  .player { padding: 6px 8px; gap: 0 6px; flex-wrap: wrap; }
  .tot { order: 3; flex-basis: 100%; padding-left: 22px; }
  .player.right .tot { padding-left: 0; padding-right: 22px; }
  .vs { min-width: 44px; }
  .scorecard table { font-size: .74rem; }
}

/* Einladungs-Karte aus dem gemeinsamen Kern (core.js) */
:root { --pf-card: var(--card); --pf-text: var(--text); --pf-muted: var(--muted); --pf-line: var(--line); --pf-bg: var(--bg);
  --pf-accent: var(--accent); --pf-accent-text: var(--accent-text); --pf-shadow: var(--shadow); --pf-veil: rgba(10, 25, 12, .38); --pf-veil-radius: 18px; }
