:root {
  --bg: #14171c;
  --panel: #1c2028;
  --panel-raised: #242a34;
  --line: #333a46;
  --text: #eef0f3;
  --text-dim: #9aa3b2;
  --accent: #e27a42;
  --accent-dim: #7a4227;
  --hit: #4caf7d;
  --miss: #b85c5c;
  --warn: #d9a441;
  font-size: 16px;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  height: 100%;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
}

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

/* --- Statusleiste --- */
#statusbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  background: var(--panel-raised);
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; flex-shrink: 0; }
.dot.online { background: var(--hit); }
.dot.offline { background: var(--warn); }

#pending { color: var(--text-dim); flex: 1; }

#syncBtn {
  background: var(--accent-dim);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
}
#syncBtn:active { background: var(--accent); }

/* --- Screens --- */
.screen { display: none; padding: 1rem; flex: 1; }
.screen.active { display: flex; flex-direction: column; gap: 1rem; }

h1 { font-size: 1.3rem; margin: 0 0 0.3rem; }
h2 { font-size: 1rem; color: var(--text-dim); margin: 0 0 0.4rem; font-weight: 600; }
p.hint { color: var(--text-dim); font-size: 0.85rem; margin: 0; }

label { font-size: 0.85rem; color: var(--text-dim); display: block; margin-bottom: 0.3rem; }

input[type="text"], input[type="date"], input[type="url"], select {
  width: 100%;
  padding: 0.7rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 1rem;
}

.field { margin-bottom: 0.8rem; }

.primary-btn {
  background: var(--accent);
  color: #14171c;
  font-weight: 700;
  padding: 0.9rem;
  border-radius: 0.6rem;
  font-size: 1rem;
}
.primary-btn:active { opacity: 0.85; }

.secondary-btn {
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0.7rem;
  border-radius: 0.6rem;
  font-size: 0.9rem;
}

/* --- Live-Erfassung --- */
#halbzeitToggle { display: flex; gap: 0.5rem; }
#halbzeitToggle button {
  flex: 1;
  padding: 0.6rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--text-dim);
  font-weight: 600;
}
#halbzeitToggle button.active { background: var(--accent); color: #14171c; border-color: var(--accent); }

#playerStrip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
}
.player-chip {
  flex-shrink: 0;
  padding: 0.6rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2rem;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}
.player-chip.selected { background: var(--accent); color: #14171c; border-color: var(--accent); }
.player-chip .num { opacity: 0.7; font-weight: 400; margin-right: 0.3rem; }

.action-group { background: var(--panel); border-radius: 0.7rem; padding: 0.7rem; }
.action-group h2 { margin-bottom: 0.6rem; }

.wurf-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
}
.wurf-row .zone { font-size: 0.95rem; }
.wurf-row button {
  padding: 0.7rem 1rem;
  border-radius: 0.5rem;
  font-weight: 700;
  min-width: 4.5rem;
}
.wurf-row .btn-treffer { background: var(--hit); color: #0e1712; }
.wurf-row .btn-treffer:active { filter: brightness(1.15); }
.wurf-row .btn-fehlwurf { background: var(--panel-raised); color: var(--text-dim); border: 1px solid var(--line); }
.wurf-row .btn-fehlwurf:active { background: var(--miss); color: #fff; }

.btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.5rem;
}
.btn-grid button {
  padding: 0.8rem 0.4rem;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}
.btn-grid button:active { background: var(--accent); color: #14171c; }

#lastEvents {
  background: var(--panel);
  border-radius: 0.7rem;
  padding: 0.7rem;
}
#lastEvents ul { list-style: none; margin: 0; padding: 0; max-height: 8rem; overflow-y: auto; }
#lastEvents li {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
#lastEvents li:last-child { border-bottom: none; }
#lastEvents .undo-btn {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8rem;
}

nav.tabbar {
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--panel-raised);
}
nav.tabbar button {
  flex: 1;
  padding: 0.8rem;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 600;
}
nav.tabbar button.active { color: var(--accent); }
