:root {
  --bg: #0b1f15;
  --bg2: #10291c;
  --card: #143322;
  --line: #24503a;
  --text: #eef5ef;
  --muted: #9bb8a6;
  --accent: #f3c614;
  --good: #46d17f;
  --bad: #ff6b5e;
  --open: #6fb6ff;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #1a4a30, var(--bg)) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; margin-top: .4em; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.error { color: var(--bad); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(8, 24, 16, .85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; }
#nav { display: flex; gap: 14px; flex-wrap: wrap; }
#nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
#nav a:hover { color: var(--text); }

main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: .9rem; }
input[type=text], input[type=password], input:not([type]) {
  font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  font: inherit; font-weight: 600; color: var(--text); background: #1d4a32; border: 1px solid #2f6a4a;
  border-radius: 10px; padding: 10px 16px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; touch-action: manipulation;
}
.btn:hover { background: #245a3d; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: #1c1600; border-color: #d9af00; }
.btn.primary:hover { background: #ffd83a; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: .9rem; }
.btn.big { padding: 12px 28px; font-size: 1.15rem; flex: 1; }
.btn.on { border-color: var(--accent); color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 99px; background: #1d4a32; color: var(--accent); font-size: .85rem; }

.tabs { display: flex; gap: 6px; margin: 12px 0; }
.tab { flex: 1; font: inherit; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.tab.active { background: #1d4a32; color: var(--text); }

.hero { padding: 8px 0 16px; }
.variants { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.variant {
  font: inherit; text-align: left; cursor: pointer; color: var(--text); padding: 18px; border-radius: var(--radius);
  border: 1px solid #2f6a4a; background: linear-gradient(160deg, #1f5a3a, #143322); display: grid; gap: 4px;
}
.variant b { font-size: 1.4rem; } .variant span { color: var(--muted); font-size: .9rem; }
.variant:hover { border-color: var(--accent); }
.seg { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.seg button { font: inherit; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.seg button.on { background: #1d4a32; color: var(--text); border-color: var(--accent); }

.games { list-style: none; margin: 0; padding: 0; }
.games a { display: grid; grid-template-columns: 70px 1fr auto 60px; gap: 10px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.games a:hover { background: #18402a; }
.games .v { font-weight: 700; } .games .when { color: var(--muted); font-size: .9rem; }
.games .st { font-size: .85rem; color: var(--muted); } .games .st.active { color: var(--accent); }
.games .pts { text-align: right; font-size: 1.15rem; }

/* Spiel */
.game { display: grid; gap: 12px; grid-template-columns: 1fr; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; min-width: 0; }
.stats small { display: block; color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats b { font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.tablewrap { position: relative; height: min(68vh, 760px); display: flex; align-items: center; justify-content: center; }
.tablewrap canvas { touch-action: none; display: block; border-radius: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.45); cursor: crosshair; }
.skip { position: absolute; right: 8px; bottom: 8px; }
.side { min-width: 0; }
.hint { margin: 0 0 8px; color: var(--muted); font-size: .92rem; }
.spinrow { display: flex; gap: 14px; align-items: center; margin-top: 12px; }
.spinpad {
  width: 84px; height: 84px; flex: none; border-radius: 50%; position: relative; cursor: crosshair; touch-action: none;
  background: radial-gradient(circle at 35% 30%, #ff8a80, #c4161c 55%, #5e0508); box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.spinpad::before, .spinpad::after { content: ''; position: absolute; background: rgba(255,255,255,.25); }
.spinpad::before { left: 50%; top: 12%; bottom: 12%; width: 1px; }
.spinpad::after { top: 50%; left: 12%; right: 12%; height: 1px; }
.spinpad i {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: #2b6ea8; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.6); z-index: 1;
}
.spinrow .btn { margin-top: 6px; }
.meter { flex: 1; position: relative; height: 40px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); overflow: hidden; }
.meter #powbar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--good); transition: width .05s; }
.meter span { position: relative; display: grid; place-items: center; height: 100%; font-weight: 600; font-size: .92rem; text-shadow: 0 1px 2px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.power { display: grid; grid-template-columns: auto 1fr 52px; align-items: center; gap: 10px; color: var(--text); }
.power input { width: 100%; accent-color: var(--accent); height: 28px; }
.power output { text-align: right; font-variant-numeric: tabular-nums; }
.result .pts { display: flex; align-items: baseline; justify-content: space-between; }
.result .pts b { font-size: 2.2rem; }
.result.good .pts b { color: var(--good); } .result.bad .pts b { color: var(--bad); } .result.open .pts b { color: var(--open); }
.result.bad { border-color: #7a2c26; } .result.good { border-color: #2c7a4c; }
.fouls { list-style: none; padding: 0; margin: 6px 0; color: var(--bad); font-weight: 600; }
.fouls small { color: var(--muted); font-weight: 400; }
.why { margin: 6px 0; padding-left: 18px; }
.refs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.refs span { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: #0f2a1c; color: var(--muted); border: 1px solid var(--line); }
.refs .ausl { color: var(--open); cursor: help; }
.sheet summary { cursor: pointer; font-weight: 700; }
.sheetlist { list-style: none; padding: 0; margin: 8px 0 0; max-height: 300px; overflow: auto; }
.sheetlist li { display: grid; grid-template-columns: 36px 40px 40px 1fr; gap: 6px; padding: 5px 4px; border-bottom: 1px solid var(--line); cursor: pointer; font-variant-numeric: tabular-nums; }
.sheetlist li:hover { background: #18402a; }
.sheetlist li.muted { display: block; cursor: default; }
.sheetlist li.good b { color: var(--good); } .sheetlist li.foul b { color: var(--bad); } .sheetlist li.open b { color: var(--open); }
.sheetlist .run { color: var(--muted); } .sheetlist em { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ruleset { font-size: .78rem; }

@media (min-width: 980px) {
  .game { grid-template-columns: 1fr 380px; grid-template-areas: "stats side" "table side"; align-items: start; }
  .stats { grid-area: stats; } .tablewrap { grid-area: table; height: calc(100vh - 170px); min-height: 420px; }
  .side { grid-area: side; position: sticky; top: 70px; max-height: calc(100vh - 86px); overflow: auto; }
}

/* Auswertung */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 10px 0; }
.tiles > div { background: var(--bg2); border-radius: 12px; padding: 10px 12px; }
.tiles small { display: block; color: var(--muted); } .tiles b { font-size: 1.6rem; }
.chart svg { width: 100%; height: auto; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart .zero { stroke: var(--line); stroke-dasharray: 4 4; }
.chart .lbl { fill: var(--muted); font-size: 12px; }
.chart figcaption { text-align: center; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.foul td:nth-child(2) { color: var(--bad); }
.tbl .f { color: var(--bad); }
.scroll { overflow-x: auto; }
.sheet-table td:nth-child(4) { min-width: 220px; }

.prose { max-width: 980px; margin: 0 auto 16px; }
.prose h1 { margin-top: .2em; } .prose h2 { margin-top: 1.4em; } .prose h3 { margin-top: 1.1em; }
.prose code { background: var(--bg2); padding: 1px 5px; border-radius: 5px; }
.prose blockquote { margin: 0 0 1em; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--bg2); border-radius: 0 10px 10px 0; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.overlay .big { font-size: 3rem; font-weight: 800; margin: 0; color: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%); transition: transform .25s;
  background: #1d4a32; border: 1px solid #2f6a4a; color: var(--text); padding: 10px 16px; border-radius: 12px; z-index: 60;
  max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.4); visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; } #toast.bad { border-color: var(--bad); }

@media (max-width: 560px) {
  main { padding: 10px; }
  .brand span { display: none; }
  #nav { gap: 12px; flex-wrap: nowrap; } #nav a { font-size: .9rem; white-space: nowrap; }
  .stats b { font-size: 1.05rem; }
  .games a { grid-template-columns: 80px 1fr 50px; } .games .when { display: none; }
}

@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; }
  .topbar, .noprint, #toast { display: none !important; }
  .card { border: 1px solid #bbb; background: #fff; break-inside: avoid; }
  .muted, .tbl th { color: #444; }
  .tiles > div { background: #f2f2f2; }
  .tbl th, .tbl td { border-color: #ccc; }
  .chart .line { stroke: #000; }
}

/* Windows-Programm: Installationshinweis, Download, Geräte */
.installbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.installbar > span:first-child { font-size: 1.6rem; }
.installbar div { flex: 1; display: grid; } .installbar small { color: var(--muted); }
.installbar .go { font-size: 1.6rem; color: var(--muted); }
.installbar.win { border-color: var(--accent); background: linear-gradient(90deg, #2a3a14, var(--card)); }
.installbar:hover { border-color: var(--accent); }
.download .btn.big { display: block; text-align: center; text-decoration: none; margin: 12px 0; }
.download .steps li { margin-bottom: 6px; }
.devices { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.devices li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; }
.pill.bad { color: var(--bad); border-color: var(--bad); }
