/* ===========================================================
   FrisbeeGolf – dunkles, responsives Layout
   =========================================================== */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1f2730;
  --border: #2d3744;
  --text: #e6edf3;
  --muted: #8b97a5;
  --accent: #4cc2ff;
  --accent-2: #2ea043;
  --danger: #f85149;
  --gold: #ffd34d;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100dvh;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 {
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: 0.5px;
}
.icon-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.1rem;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--panel-2); }

/* ---------- Scoreboard ---------- */
.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Spielfeld ---------- */
.stage {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 450 / 600;
  width: 100%;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---------- Kraft-Leiste ---------- */
.power-wrap {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 46px;
  background: rgba(13, 17, 23, 0.78);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}
.power-wrap.active { opacity: 1; }
.power-label {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
}
.power-track {
  width: 16px;
  height: 150px;
  background: var(--panel-2);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}
.power-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, var(--accent-2), var(--gold), var(--danger));
  transition: height 0.04s linear;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 16, 0.86);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 5;
}
.overlay.hidden { display: none; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: var(--shadow);
  max-height: 100%;
  overflow-y: auto;
}
.panel h2 { margin: 0 0 8px; font-size: 1.5rem; }
.panel h3 { margin: 16px 0 8px; font-size: 1rem; color: var(--accent); }
.panel p { margin: 6px 0; color: var(--muted); line-height: 1.45; }
.panel .result { color: var(--text); font-size: 1.05rem; }
.panel .result strong { color: var(--gold); font-size: 1.25rem; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  margin: 14px 0;
}
.field span { font-size: 0.8rem; color: var(--muted); }
.field input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
}
.field input:focus { outline: 2px solid var(--accent); }

button.primary {
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: filter 0.15s;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:active { transform: translateY(1px); }

/* ---------- Legende ---------- */
.legend { margin-top: 16px; text-align: left; }
.legend ul { margin: 6px 0; padding-left: 0; list-style: none; }
.legend li {
  margin: 6px 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.legend .hint { font-size: 0.78rem; margin-top: 8px; }
kbd {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text);
}

/* ---------- Bestenliste ---------- */
.highscores {
  text-align: left;
  margin: 8px 0;
  padding-left: 28px;
  max-height: 220px;
  overflow-y: auto;
}
.highscores li {
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.highscores li.me { color: var(--gold); font-weight: 700; }
.highscores .hs-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.highscores .hs-score { font-variant-numeric: tabular-nums; }
.highscores .empty { color: var(--muted); list-style: none; margin-left: -16px; }

/* ---------- Touch-Steuerung ---------- */
.touch-controls {
  display: none;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 8px;
}
.touch-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  font-size: 1.3rem;
  height: 56px;
  min-width: 56px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.touch-btn:active { background: var(--panel-2); }
.touch-fine { display: flex; flex-direction: column; gap: 4px; }
.touch-btn.small { height: 26px; font-size: 0.85rem; }
.touch-btn.throw {
  background: var(--accent-2);
  color: #fff;
  font-weight: 800;
  letter-spacing: 1px;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

/* ---------- Mobile ---------- */
@media (hover: none) and (pointer: coarse) {
  .touch-controls { display: grid; }
}
@media (max-width: 420px) {
  .topbar h1 { font-size: 1.15rem; }
  .stat-value { font-size: 0.95rem; }
}
