* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d10;
  --card: #1b1b22;
  --card2: #24242d;
  --text: #f2f2f5;
  --muted: #9a9aa5;
  --yellow: #fdda25;
  --red: #ef3340;
  --green1: #2e7d3d;
  --green2: #2a7238;
  --line: rgba(255, 255, 255, 0.55);
}

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

header { text-align: center; margin-bottom: 18px; }

h1 {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}
h1 .rudi {
  color: var(--yellow);
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 5px;
  text-underline-offset: 6px;
}

.sub { color: var(--muted); margin-top: 12px; font-size: 0.85rem; }
.sub b { color: var(--text); white-space: nowrap; }

h2 { font-size: 1.15rem; margin: 10px 0 14px; }
h3 { font-size: 1rem; margin: 22px 0 10px; color: var(--yellow); }

.step {
  display: inline-flex;
  width: 24px; height: 24px;
  align-items: center; justify-content: center;
  background: var(--red);
  border-radius: 50%;
  font-size: 0.85rem;
  margin-right: 6px;
}

.hidden { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; -webkit-tap-highlight-color: transparent; }

/* ---------- formatie ---------- */

#formation-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.formation-card {
  background: var(--card);
  border: 1px solid #2e2e38;
  border-radius: 12px;
  padding: 12px 10px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.06s ease;
}
.formation-card:active { transform: scale(0.97); }
.formation-card .f { font-size: 1.25rem; font-weight: 800; color: var(--yellow); word-break: break-all; }
.formation-card .tag { font-size: 0.78rem; color: var(--muted); }

.custom-formation { display: flex; gap: 8px; margin-top: 14px; }
.custom-formation input {
  flex: 1;
  background: var(--card);
  border: 1px solid #2e2e38;
  border-radius: 10px;
  color: var(--text);
  padding: 12px;
  font-size: 1rem;
}
.custom-formation button {
  background: var(--yellow);
  color: #111;
  font-weight: 800;
  border-radius: 10px;
  padding: 0 18px;
}

.error { color: var(--red); font-size: 0.85rem; margin-top: 8px; }

.banner {
  background: var(--card);
  border: 1px solid #3a3a1f;
  border-left: 4px solid var(--yellow);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.banner button {
  background: none;
  color: var(--yellow);
  font-weight: 700;
  padding: 4px 0 0;
  display: block;
}

/* ---------- veld ---------- */

.pitch-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.pitch-head h2 { margin: 0; color: var(--yellow); }
.pitch-hint { color: var(--muted); font-size: 0.75rem; margin-left: auto; }

.ghost { background: none; color: var(--muted); padding: 4px 6px 4px 0; }

.pitch {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: repeating-linear-gradient(
    to bottom,
    var(--green1) 0, var(--green1) 40px,
    var(--green2) 40px, var(--green2) 80px
  );
  min-height: 460px;
  overflow: hidden;
}

.marking { position: absolute; border-color: var(--line); pointer-events: none; }
.center-circle {
  top: 50%; left: 50%;
  width: 90px; height: 90px;
  margin: -45px 0 0 -45px;
  border: 2px solid var(--line);
  border-radius: 50%;
}
.half-line { top: 50%; left: 0; right: 0; border-top: 2px solid var(--line); }
.box-top {
  top: -2px; left: 50%;
  width: 55%; height: 48px;
  transform: translateX(-50%);
  border: 2px solid var(--line);
  border-top: 0;
}
.box-bottom {
  bottom: -2px; left: 50%;
  width: 55%; height: 48px;
  transform: translateX(-50%);
  border: 2px solid var(--line);
  border-bottom: 0;
}

.rows {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  min-height: 460px;
  padding: 6px 2px;
}

.pitch-row { display: flex; justify-content: space-evenly; align-items: flex-start; }

.slot {
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  flex: 0 1 auto;
  padding: 0 1px;
}
.slot .dot {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  background: rgba(0, 0, 0, 0.25);
  border: 2px dashed rgba(255, 255, 255, 0.7);
  color: #fff;
  transition: transform 0.06s ease;
}
.slot:active .dot { transform: scale(0.92); }
.slot.filled .dot { background: var(--red); border: 2px solid #fff; }
.slot.gk.filled .dot { background: var(--yellow); }
.slot .nm {
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  max-width: 72px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pitch-row.crowded .slot .dot { width: 30px; height: 30px; font-size: 0.9rem; }
.pitch-row.crowded .slot .nm { max-width: 34px; font-size: 0.55rem; }

/* read-only mini pitch (people's eleven, "my eleven" detail) */
.pitch.small { min-height: 350px; margin-top: 4px; }
.pitch.small .rows { min-height: 350px; }
.pitch.small .slot { cursor: default; }
.pitch.small .slot:active .dot { transform: none; }
.pitch.small .slot .dot { width: 34px; height: 34px; font-size: 1rem; }
.pitch.small .slot .nm { max-width: 58px; font-size: 0.6rem; }
.pitch.small .pitch-row.crowded .slot .dot { width: 26px; height: 26px; font-size: 0.8rem; }
.pitch.small .pitch-row.crowded .slot .nm { max-width: 30px; font-size: 0.5rem; }
.pitch.small .center-circle { width: 70px; height: 70px; margin: -35px 0 0 -35px; }

.cta {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: var(--red);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: 12px;
  padding: 15px;
}
.cta:disabled { background: var(--card2); color: var(--muted); cursor: default; }

/* ---------- kiezer ---------- */

#picker {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  background: var(--card);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.sheet-head button { background: var(--card2); border-radius: 50%; width: 30px; height: 30px; }
#picker-search {
  background: var(--card2);
  border: 1px solid #34343f;
  border-radius: 10px;
  color: var(--text);
  padding: 12px;
  font-size: 1rem;
}
#picker-list { overflow-y: auto; }

.group-title {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 12px 0 6px;
}
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  background: var(--card2);
  border: 1px solid #34343f;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 0.88rem;
}
.chip:active { background: var(--red); }
.chip.picked { border-color: var(--yellow); color: var(--yellow); }
.chip.custom { background: var(--yellow); color: #111; font-weight: 700; align-self: flex-start; }
.chip.remove { background: none; border-color: var(--red); color: var(--red); align-self: flex-start; }

/* ---------- stats ---------- */

.stat-hero {
  text-align: center;
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 6px;
}
.stat-hero div { font-size: 3rem; font-weight: 900; color: var(--yellow); line-height: 1; }
.stat-hero p { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }

.bar-row {
  display: grid;
  /* cap the label column so conga-length formations wrap instead of eating the bar */
  grid-template-columns: minmax(52px, 92px) 1fr 34px;
  gap: 8px;
  align-items: center;
  margin-bottom: 7px;
  font-size: 0.9rem;
}
.bar-row.mine .bar-label { color: var(--yellow); }
.bar-row.mine .bar-label::after { content: " ← jij"; font-size: 0.7rem; }
.bar-label { font-weight: 700; word-break: break-all; }
.bar { background: var(--card); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--red)); border-radius: 6px; }
.bar-count { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.ranklist { list-style: none; counter-reset: rank; }
.ranklist li {
  counter-increment: rank;
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid #26262e;
  font-size: 0.92rem;
}
.ranklist li::before {
  content: counter(rank) ".";
  color: var(--muted);
  margin-right: 10px;
  min-width: 22px;
  display: inline-block;
}
.ranklist li span { flex: 1; }
.ranklist li b { color: var(--yellow); font-variant-numeric: tabular-nums; }

.rankcard {
  background: var(--card);
  border: 1px solid #3a3a1f;
  border-left: 4px solid var(--yellow);
  border-radius: 10px;
  padding: 12px;
  margin: 14px 0;
  font-size: 0.9rem;
}
.rankcard b { color: var(--yellow); }
.rank-toggle {
  background: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 8px 0 0;
  display: block;
}

.crowd-sub { color: var(--muted); font-size: 0.8rem; margin: -4px 0 8px; }

/* CSS Belgian flag — Windows has no flag emoji, 🇧🇪 renders as "BE" there */
.beflag {
  display: inline-block;
  width: 21px;
  height: 14px;
  vertical-align: baseline;
  border-radius: 2px;
  background: linear-gradient(90deg, #000 0 33.4%, var(--yellow) 33.4% 66.7%, var(--red) 66.7%);
}

.topteam {
  background: var(--card);
  border: 1px solid #3a3a1f;
  border-radius: 12px;
  padding: 12px;
  margin-top: 20px;
  font-size: 0.9rem;
}
.topteam h3 { margin: 0 0 6px; }
.topteam .tt-players { color: var(--muted); margin-top: 6px; font-size: 0.82rem; }

.stats-actions { margin-top: 24px; display: flex; flex-direction: column; gap: 6px; }
.stats-actions .ghost { text-align: center; padding: 10px; }

footer {
  margin-top: 36px;
  text-align: center;
  color: #5c5c66;
  font-size: 0.72rem;
  line-height: 1.6;
}
footer a { color: var(--yellow); text-decoration: none; }
footer a:hover { text-decoration: underline; }
