/* Lines of Action – App-Shell, randlos, kein Scroll. */
:root {
  --bg: #0a0a14;
  --fg: #eef1f6;
  --muted: #99a0b0;
  --accent: #c79cff;
  --accent-2: #a678f0;
  --board-bg: #151a24;
  --sq-dark: #202a3a;
  --sq-light: #2a3547;
  --piece-black: radial-gradient(circle at 38% 32%, #3a4a63, #10151f 72%);
  --piece-white: radial-gradient(circle at 38% 32%, #fbf7ec, #cbc3ad 78%);
  --danger: #e0704f;
  --ok: #58c47a;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  min-height: 100dvh; height: 100dvh; overflow: hidden;
  background: var(--bg); color: var(--fg);
  display: flex; flex-direction: column; align-items: center;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.bg-grid {
  position: fixed; inset: 0; z-index: -1; opacity: 0.5;
  background:
    radial-gradient(circle at 50% 0%, rgba(199,156,255,0.12), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 40px);
}

.top {
  flex: 0 0 auto; width: 100%; max-width: 640px;
  padding: 0.5rem 1.1rem 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.back { color: var(--muted); text-decoration: none; font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.back:hover { color: var(--accent); }
.game-title { margin: 0; font-size: 1.1rem; font-weight: 800; letter-spacing: 0.02em; color: var(--accent); text-align: center; }
.btn { font: inherit; font-weight: 700; color: var(--fg); background: var(--board-bg); border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; padding: 0.45rem 0.9rem; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn-primary { border-color: transparent; background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #1a0f2e; }

.wrap {
  flex: 1 1 auto; min-height: 0; width: 100%; max-width: 640px;
  padding: 0.4rem 0.9rem 0.5rem; display: flex; flex-direction: column; align-items: stretch; gap: 0.4rem;
}

/* HUD */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.85rem; }
.side { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.side-name { font-weight: 700; color: var(--fg); }
.side-groups { font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.chip { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 1px solid rgba(255,255,255,0.2); }
.chip-black { background: var(--piece-black); }
.chip-white { background: var(--piece-white); }
.turn { font-weight: 800; color: var(--accent-2); text-align: center; }
.side.is-turn .side-name { color: var(--accent); }

/* Brett */
.stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.board {
  width: min(96vw, 62vh); aspect-ratio: 1; max-width: 540px;
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  border-radius: 10px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 18px 50px -22px rgba(0,0,0,0.8);
  container-type: size;
}
.sq {
  position: relative; display: flex; align-items: center; justify-content: center;
  cursor: default;
}
.sq.d { background: var(--sq-dark); }
.sq.l { background: var(--sq-light); }
.sq.last { box-shadow: inset 0 0 0 3px rgba(199,156,255,0.5); }
.sq.pickable { cursor: pointer; }
.sq.sel { box-shadow: inset 0 0 0 3px var(--accent); }
.sq.win { background: rgba(88,196,122,0.35) !important; }

.piece {
  width: 78%; height: 78%; border-radius: 50%;
  box-shadow: 0 3px 6px -2px rgba(0,0,0,0.6);
  pointer-events: none;
}
.piece.b { background: var(--piece-black); border: 1px solid rgba(0,0,0,0.5); }
.piece.w { background: var(--piece-white); border: 1px solid rgba(0,0,0,0.25); }

/* Zug-Marker */
.dot { position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(199,156,255,0.7); pointer-events: none; }
.ring { position: absolute; inset: 8%; border-radius: 50%; border: 3px solid var(--danger); pointer-events: none; box-sizing: border-box; }
.sq.moveable { cursor: pointer; }

.msg { flex: 0 0 auto; min-height: 1.3rem; margin: 0; text-align: center; font-size: 0.9rem; font-weight: 700; color: var(--accent-2); }

/* Bestenliste (wandert per arcade-scores ins Modal) */
.leaderboard { width: 100%; max-width: 640px; }
.wrap > .leaderboard { display: none; }
.lb-title { margin: 0 0 0.2rem; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.lb-sub { margin: 0 0 0.7rem; font-size: 0.8rem; color: var(--muted); }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-empty { color: var(--muted); font-size: 0.9rem; padding: 0.4rem 0; }
.lb-row { display: grid; grid-template-columns: 2.6rem 1fr auto; align-items: center; gap: 0.6rem; padding: 0.5rem 0.7rem; margin-bottom: 0.35rem; border: 1px solid rgba(255,255,255,0.07); border-radius: 10px; background: var(--board-bg); }
.lb-rank { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-row--me { border-color: color-mix(in srgb, var(--accent) 65%, transparent); box-shadow: 0 0 22px -10px var(--accent); }

/* Overlay */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(4,6,12,0.72); backdrop-filter: blur(3px); }
.overlay[hidden] { display: none; }
.overlay-card { position: relative; width: min(94vw, 380px); background: var(--board-bg); border: 1px solid rgba(255,255,255,0.1); border-radius: 18px; padding: 1.4rem 1.3rem; text-align: center; box-shadow: 0 24px 60px -20px rgba(0,0,0,0.8); }
.overlay-close { position: absolute; top: 0.6rem; right: 0.6rem; width: 1.9rem; height: 1.9rem; border-radius: 8px; background: none; border: 1px solid rgba(255,255,255,0.14); color: var(--muted); font-weight: 800; cursor: pointer; }
.overlay-title { margin: 0.2rem 0 0.3rem; font-size: 1.5rem; color: var(--accent); }
.overlay-sub { margin: 0 0 0.9rem; color: var(--muted); }
.overlay-actions { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }
.lb-form { margin: 0.6rem 0; }
.lb-form-label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.4rem; }
.lb-form-row { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.lb-form-row input { flex: 1; min-width: 7rem; font: inherit; font-weight: 700; color: var(--fg); background: var(--sq-dark); border: 1px solid rgba(255,255,255,0.16); border-radius: 10px; padding: 0.5rem 0.7rem; }
.lb-result { color: var(--accent-2); font-weight: 700; margin: 0.3rem 0; }
.streak { color: var(--muted); margin: 0.2rem 0 0.6rem; }
.streak b { color: var(--fg); }
