*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg-1: #1d2b3a;
  --bg-2: #0f1720;
  --wood-1: #b8804a;
  --wood-2: #8a5a2e;
  --wood-3: #6b421f;
  --hole: #4a2c12;
  --text: #f3ece2;
  --muted: #b9c3cf;
  --accent: #ffcf5c;
  --ok: #7ee08a;
  --cell: min(11vw, 64px);
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% 0%, var(--bg-1), var(--bg-2) 70%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px;
}

.app {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

header {
  text-align: center;
}

h1 {
  margin: 8px 0 4px;
  font-size: clamp(2rem, 7vw, 2.8rem);
  letter-spacing: 0.04em;
  color: var(--accent);
  text-shadow: 0 2px 12px rgba(255, 207, 92, 0.35);
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

/* ---------- Statistiken ---------- */
.stats {
  display: flex;
  gap: 12px;
}

.stat {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px 16px;
  min-width: 86px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ---------- Brett ---------- */
.board-wrap {
  padding: calc(var(--cell) * 0.35);
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 30% 30%, rgba(0, 0, 0, 0.05) 0 3px, transparent 3px 9px),
    radial-gradient(circle at 35% 30%, var(--wood-1), var(--wood-2) 60%, var(--wood-3));
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.55),
    inset 0 4px 10px rgba(255, 255, 255, 0.25),
    inset 0 -8px 16px rgba(0, 0, 0, 0.35);
}

.board {
  display: grid;
  grid-template-columns: repeat(7, var(--cell));
  grid-template-rows: repeat(7, var(--cell));
  touch-action: none;
  user-select: none;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.hole {
  width: 62%;
  height: 62%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 60%, var(--hole), #2b1808);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.hole.target {
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.7),
    0 0 0 3px var(--ok),
    0 0 14px var(--ok);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.1);
  }
}

.marble {
  position: absolute;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  cursor: grab;
  background: radial-gradient(circle at 32% 28%, #ffffff 0 6%, #7fc3ff 18%, #2a78d6 55%, #123f7a 100%);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5), inset 0 -3px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 1;
}

.marble:hover {
  transform: scale(1.06);
}

.marble.movable {
  /* dezente Markierung für Murmeln, die ziehen können */
}

.marble.selected {
  transform: scale(1.15) translateY(-3px);
  box-shadow:
    0 10px 14px rgba(0, 0, 0, 0.5),
    0 0 0 3px var(--accent),
    0 0 18px var(--accent);
}

.marble.hint {
  animation: hint 0.6s ease-in-out 3;
}

@keyframes hint {
  50% {
    box-shadow: 0 0 0 4px var(--accent), 0 0 22px var(--accent);
    transform: scale(1.15);
  }
}

.marble.removing {
  animation: vanish 0.3s ease forwards;
}

@keyframes vanish {
  to {
    transform: scale(0);
    opacity: 0;
  }
}

.marble.landing {
  animation: land 0.25s ease;
}

@keyframes land {
  0% {
    transform: scale(1.3) translateY(-8px);
  }
  100% {
    transform: scale(1);
  }
}

.marble.dragging {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.15);
  transition: none;
}

/* ---------- Meldung & Buttons ---------- */
.message {
  min-height: 1.5em;
  margin: 0;
  text-align: center;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #2b1f05;
  border-color: transparent;
}

.btn-primary:hover:not(:disabled) {
  background: #ffdb85;
}

/* ---------- Regeln ---------- */
.rules {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px 16px;
  color: var(--muted);
}

.rules summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.rules li {
  margin: 6px 0;
}

/* ---------- Overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2000;
}

.overlay.hidden {
  display: none;
}

.dialog {
  background: linear-gradient(160deg, #24364a, #16212d);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: pop 0.3s ease;
}

.dialog h2 {
  margin-top: 0;
  color: var(--accent);
}

@keyframes pop {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}
