:root {
  --green-900: #1c2e25;
  --green-800: #263d31;
  --green-600: #3d6b4f;
  --sage: #b8c9ad;
  --sand: #f4efe4;
  --paper: #fffdf8;
  --ink: #1f2722;
  --muted: #66706a;
  --line: #e2ddd0;
  --good: #39a852;
  --warn: #d5a62e;
  --bad: #c94136;
  --radius: 14px;
  --shadow: 0 1px 2px #0000000f, 0 4px 14px #00000012;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--sand);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--green-600); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
button, input, select { font: inherit; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--green-800); color: #fff;
}
.topbar[hidden] { display: none; }
.brand { color: #fff; font-weight: 800; font-size: 1.15rem; text-decoration: none; letter-spacing: .02em; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #dfe9da; text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.topbar nav a.active { background: #ffffff1f; color: #fff; }
.money { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.link { background: none; border: 0; color: #dfe9da; cursor: pointer; padding: 6px; }

main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 48px; }

/* Bausteine */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid.cols { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 11px; padding: 10px 16px; cursor: pointer;
  background: var(--green-800); color: #fff; font-weight: 700; text-decoration: none;
}
.btn:hover { background: var(--green-900); }
.btn.secondary { background: #fff; color: var(--green-800); border: 1px solid var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #39a85266; outline-offset: 2px; }

/* Anmeldung */
.auth { max-width: 400px; margin: 6vh auto 0; }
.auth .logo { font-size: 2.2rem; font-weight: 800; color: var(--green-800); text-align: center; margin-bottom: 4px; }
.auth .tagline { text-align: center; color: var(--muted); margin-bottom: 20px; }
.pin { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.link-dark { background: none; border: 0; padding: 0; color: var(--green-600); cursor: pointer; text-decoration: underline; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; padding: 9px; border-radius: 10px; background: #ece7da; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--green-800); color: #fff; }
.error { color: var(--bad); font-size: .9rem; min-height: 1.2em; margin: 0 0 10px; }

/* Pferd */
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; color: #fff;
  box-shadow: inset 0 -6px 0 #00000026;
}
img.avatar { object-fit: cover; background: #2a211a; }
.avatar.big { width: 76px; height: 76px; }
a.visit { display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit; background: var(--green-800); color: #fff; border-color: var(--green-800); }
a.visit .muted { color: #cfe0c8; }
a.visit:hover { background: var(--green-900); }
.visit-ico { font-size: 2rem; }
.coat-chestnut { background: #a5532a; }
.coat-bay { background: #6b3e22; }
.coat-black { background: #2c2a27; }
.coat-grey { background: #cfccc4; color: var(--ink); }
.coat-palomino { background: #d3a45c; color: var(--ink); }
.coat-buckskin { background: #b88b55; }
.coat-smoky_black { background: #3c332d; }
.coat-cremello, .coat-perlino, .coat-smoky_cream { background: #ecdcc0; color: var(--ink); }
.coat-red_dun { background: #c08657; }
.coat-bay_dun { background: #b8955f; }
.coat-grullo { background: #756c63; }
.horse-card { display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: inherit; }
.horse-card:hover { border-color: var(--green-600); }
.horse-head { display: flex; gap: 12px; align-items: center; }
.horse-head h2 { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .78rem; padding: 3px 9px; border-radius: 99px; background: #fbeaea; color: var(--bad); font-weight: 600; }
.chip.ok { background: #e6f4e8; color: #2b7d3e; }

.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 112px 1fr 38px; gap: 8px; align-items: center; font-size: .88rem; }
.bar .track { height: 10px; border-radius: 6px; background: #ece7da; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 6px; transition: width .4s; }
.bar .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.lvl-good { background: var(--good); }
.lvl-warn { background: var(--warn); }
.lvl-bad { background: var(--bad); }
.lvl-stat { background: var(--green-600); }

.stars { position: relative; display: inline-block; color: #d9cfae; letter-spacing: 1px; white-space: nowrap; font-size: .9rem; line-height: 1; }
.stars .on { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: #c99a1c; }
.stat-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; }
.stat-row .bar { grid-column: 1 / -1; grid-template-columns: 1fr 38px; }

.detail { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .detail { grid-template-columns: 1.1fr 1fr; } }
.form-badge { margin-left: auto; text-align: center; }
.form-badge b { display: block; font-size: 1.6rem; line-height: 1; }

.care-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.care-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; cursor: pointer;
}
.care-btn:hover:not(:disabled) { border-color: var(--green-600); background: #f6faf4; }
.care-btn:disabled { cursor: not-allowed; background: #f3f1ea; color: var(--muted); }
.care-btn .ico { font-size: 1.3rem; }
.care-btn .lbl { font-weight: 700; }
.care-btn .sub { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.ratings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.ratings div { background: #f4f1e8; border-radius: 10px; padding: 10px 4px; }
.ratings b { display: block; font-size: 1.35rem; }
.ratings .focus { background: #e3efe0; }

table.ledger { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.ledger td, table.ledger th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.ledger td.num, table.ledger th.num { text-align: right; }
.plus { color: #2b7d3e; }
.minus { color: var(--bad); }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--green-900); color: #fff; padding: 10px 16px; border-radius: 12px; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }

.loading { text-align: center; color: var(--muted); padding: 40px 0; }

@media (max-width: 560px) {
  .topbar { gap: 8px; flex-wrap: wrap; }
  .topbar .link { padding: 6px 0; }
  .bar { grid-template-columns: 92px 1fr 34px; }
}

/* Training & Service */
.train-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; margin-bottom: 8px; }
.train-opt {
  display: flex; align-items: center; gap: 8px; text-align: left; font-weight: 600; font-size: .88rem;
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
.train-opt span:last-child { overflow-wrap: anywhere; }
.train-opt.on { border-color: var(--green-800); background: #e3efe0; }
.train-opt .ico { font-size: 1.15rem; }
.seg { display: inline-flex; background: #ece7da; border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; border-radius: 8px; padding: 6px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--green-800); box-shadow: 0 1px 2px #0002; }
.result { background: #eef6ec; border: 1px solid #cfe5ca; border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.result.bad { background: #fbeceb; border-color: #f0c9c5; }
ul.history { list-style: none; margin: 0; padding: 0; }
ul.history li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
ul.history li:last-child { border-bottom: 0; }

/* Turniere */
.show-card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; padding: 14px; box-shadow: none; }
.show-card:hover { border-color: var(--green-600); }
.enter-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.enter-row:last-child { border-bottom: 0; }
.enter-row .btn { flex: none; }
table.ledger tr.me td { background: #eef6ec; }
table.results td:first-child { font-weight: 700; width: 2.5em; }
.plan-row { display: grid; grid-template-columns: 130px 1fr; gap: 14px; margin-top: 12px; align-items: start; }
svg.course-plan { width: 130px; height: auto; background: #4f6b3f; border-radius: 10px; }
svg.course-plan rect { fill: #d8c59e; stroke: #fffdf8; stroke-width: .25; }
svg.course-plan .route { fill: none; stroke: #263d3199; stroke-width: .18; stroke-dasharray: .5 .5; }
svg.course-plan .fence line { stroke: #a83b32; stroke-width: .38; stroke-linecap: round; }
svg.course-plan .fence polygon { fill: #a83b32; }
svg.course-plan .num circle { fill: #fffdf8; stroke: #263d31; stroke-width: .18; }
svg.course-plan text { font: 800 1.15px system-ui, sans-serif; fill: #263d31; text-anchor: middle; dominant-baseline: central; }
svg.course-plan text.start { font-size: 1.1px; font-weight: 700; }
@media (max-width: 520px) { .plan-row { grid-template-columns: 1fr; } svg.course-plan { width: 150px; justify-self: center; } }
.admin-horse { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.admin-horse:last-child { border-bottom: 0; }
.admin-horse .btn { padding: 7px 10px; font-size: .85rem; }
select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
@media (max-width: 560px) {
  .topbar { gap: 8px; padding-left: 10px; padding-right: 10px; flex-wrap: wrap; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .topbar nav a { white-space: nowrap; }
}
.pasture-now { background: #e6f4e8; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; }
.pasture-now .btn { padding: 6px 10px; font-size: .85rem; }
/* 3D-Pferdefotos (portrait.js) */
.thumb { margin: -18px -18px 4px; aspect-ratio: 3 / 2; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; background: #e9e3d4; position: relative; }
.thumb::after { content: '🐴'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.4rem; opacity: .25; }
.thumb img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb[class*=coat-] { background-color: #e9e3d4; }
.dealer-bar { margin: 6px 0 14px; }
.dealer-bar .seg { flex-wrap: wrap; }
/* Zucht */
table.breed-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.breed-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .75rem; padding-bottom: 2px; }
table.breed-table td { padding: 2px 0; }
.chip .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; border: 1px solid #0002; }
.chip .dot.pinto { background-image: linear-gradient(90deg, transparent 50%, #fff 50%); }
.tabs button { font-weight: 600; }
.sell-form { margin: 0; }
.sell-form input[type=number] { width: 120px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; margin-left: 4px; }
/* App installieren */
.install-card { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; position: relative; }
.install-card img { border-radius: 14px; flex: none; }
#installBanner { position: fixed; z-index: 50; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto;
  display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: #fffdf8; border-radius: 16px; box-shadow: 0 6px 28px #0004; animation: bannerIn .35s ease-out; }
#installBanner img { border-radius: 11px; flex: none; }
#installBanner .txt { flex: 1; display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
#installBanner .btn { flex: none; }
#installBanner .x { border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px; }
@keyframes bannerIn { from { transform: translateY(120%); opacity: 0; } }
/* Als installierte App: kein Überscrollen, Abstand zur Statusleiste */
@media (display-mode: standalone) { html, body { overscroll-behavior: none; } }
.test-list { columns: 2 220px; margin: 10px 0 0; padding-left: 22px; }
.test-list li { margin-bottom: 3px; break-inside: avoid; }
.seg { flex-wrap: wrap; }
body:has(#installBanner) .toast { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 84px); }
/* Reitverein & Mannschaften */
.team-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.team-row:last-of-type { border-bottom: 0; }
.team-row .btn, .club-actions .btn { padding: 5px 9px; font-size: .8rem; }
.club-actions { margin-top: 6px; gap: 6px; }
.team-form { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.team-form h3 { font-size: 1rem; }
.chip-check { display: inline-flex; align-items: center; gap: 5px; font-size: .85rem; padding: 4px 10px; border-radius: 99px; background: #f3efe4; cursor: pointer; }
.chip-check:has(input:checked) { background: #e6f4e8; color: #2b7d3e; font-weight: 600; }
.team-riders { margin-top: 4px; line-height: 1.5; }
.team-card { border-color: #c9dcc2; }
#clubSearch input { width: 170px; }
/* Stallanlage, Weiden, Erinnerung */
.pasture-row { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.pasture-row:last-of-type { border-bottom: 0; }
.pasture-pick { margin-top: 10px; padding: 8px 12px; background: #f6f2e8; border-radius: 10px; }
.pasture-pick .btn { padding: 5px 12px; font-size: .85rem; }
.geld-box { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.geld-box h3 { font-size: 1rem; margin-bottom: 4px; }
.memorial { background: #f4f1ea; }
a.replay { text-decoration: none; font-size: .8rem; padding: 0 4px; border-radius: 6px; background: #e6f4e8; }
/* Jahreszeiten */
.season-banner { display: block; margin-bottom: 12px; padding: 10px 14px; border-radius: var(--radius); text-decoration: none; color: inherit; font-size: .9rem; }
.season-banner span { color: var(--muted); }
.season-winter { background: #eaf2f8; } .season-spring { background: #fbeef3; } .season-summer { background: #fdf5dc; } .season-autumn { background: #f8eadb; }
.advent { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.door { aspect-ratio: 1; border: 0; border-radius: 10px; background: #2f5d3e; color: #fff; font-weight: 800; font-size: 1.05rem; display: grid; place-items: center; line-height: 1.1; }
.door small { display: block; font-size: .65rem; font-weight: 600; }
.door.open { background: #f3efe4; color: var(--ink); }
.door.today { background: #c0392b; box-shadow: 0 0 0 3px #f2c23088; cursor: pointer; animation: doorPulse 1.6s infinite; }
.door:disabled:not(.open) { opacity: .75; }
@keyframes doorPulse { 50% { transform: scale(1.06); } }
.jo-card { border-color: #e2c16b; background: #fffaf0; }
/* Wochen-Challenge */
.challenge-banner { background: #e8f1fb; }
.challenge .ch-ico { font-size: 1.4rem; }
.challenge.done { border-color: #9fd3a9; }
.challenge .bar { grid-template-columns: 56px 1fr; margin-top: 8px; }
.challenge .bar .num { display: none; }
.challenge.bonus { background: #fffaf0; }

/* Reitkleidung (Konto) */
.rider-look { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.rider-pic { display: block; background: var(--sand); border-radius: 10px; padding: 6px; }
.rider-parts { flex: 1; min-width: 220px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 12px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); padding: 0; cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--green-600); }
.swatches input[type=color] { width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 8px; padding: 1px; background: #fff; cursor: pointer; }

/* Admin: Vorschau einer Werbebande (wie die Bande im Spiel, 4:1) */
.sponsor-prev { display: inline-flex; align-items: center; justify-content: center; width: 128px; height: 32px; border-radius: 4px; font-weight: 800; font-size: 12px; line-height: 1; padding: 0 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); flex: none; }
.sponsor-row input[type=color] { width: 36px; height: 32px; padding: 2px; flex: none; }
.sponsor-row .btn { padding: 6px 10px; }
