:root{
  /* Pastell-seriös: hell, weich, aber nicht verspielt */
  --bg: #f5f7fb;
  --card: rgba(255,255,255,.78);
  --text: #111827;
  --muted: rgba(55,65,81,.70);
  --border: rgba(17,24,39,.10);

  --accent: rgba(109,140,255,.95);
  --accent-soft: rgba(109,140,255,.12);

  --win: #1b7a3a;
  --lose: #b4232c;

  --gold: #b8860b;

  --radius: 18px;
  --radius2: 14px; /* weniger rund */
  --shadow: 0 18px 55px rgba(16, 24, 40, .08);
  --shadow2: 0 10px 30px rgba(16, 24, 40, .06);
}

/* Base */
*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(900px 420px at 12% -10%, rgba(109,140,255,.18), transparent 60%),
              radial-gradient(820px 420px at 90% 0%, rgba(120,209,178,.14), transparent 55%),
              radial-gradient(900px 420px at 55% 115%, rgba(255,190,122,.10), transparent 60%),
              var(--bg);
}

a{ color: inherit; text-decoration: none; }

.wrap{
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

/* Topbar */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.62);
  box-shadow: var(--shadow2);
  backdrop-filter: blur(8px);
}

.brand{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 160px;
}

.logo{
  width: 26px;
  height: 26px;
  border-radius: 10px;
  background:
    radial-gradient(10px 10px at 30% 30%, rgba(255,255,255,.95), rgba(255,255,255,0)),
    linear-gradient(135deg, rgba(109,140,255,.95), rgba(120,209,178,.85));
  box-shadow: 0 10px 18px rgba(109,140,255,.18);
}

/* Buttons */
.actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(17,24,39,.12);
  background: rgba(255,255,255,.70);
  font-weight: 850;
  color: rgba(17,24,39,.92);
  cursor:pointer;
  box-shadow: 0 10px 20px rgba(16,24,40,.05);
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
  user-select:none;
}
.btn:hover{
  background: rgba(109,140,255,.10);
  border-color: rgba(109,140,255,.25);
}
.btn:active{ transform: translateY(1px); }

.btn.primary{
  background: rgba(109,140,255,.14);
  border-color: rgba(109,140,255,.30);
}
.btn.ghost{
  background: transparent;
  box-shadow: none;
}

/* Text button (Reset unten) */
.text-btn{
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  color: rgba(55,65,81,.70);
  font-weight: 850;
  text-decoration: underline;
  cursor: pointer;
  font-size: 12px;
  opacity: .78;
}
.text-btn:hover{ opacity: 1; color: rgba(17,24,39,.90); }

/* Cards & layout */
.grid{
  display:grid;
  grid-template-columns: 1.25fr .75fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
}

.card{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(17,24,39,.07);
  flex-wrap: wrap;
}

.title h2{
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.sub{
  margin-top: 4px;
  font-size: 12px;
  color: rgba(55,65,81,.68);
  font-weight: 750;
}

/* Tools / pills */
.tools{
  display:flex;
  gap: 10px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap: wrap;
  min-width: 0;
}
.pill{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius2);
  border: 1px solid var(--border);
  background: rgba(255,255,255,.62);
  min-width: 0;
}
.pill label{
  font-size: 11px;
  color: rgba(55,65,81,.68);
  font-weight: 850;
  letter-spacing: .02em;
  white-space: nowrap;
}
.pill input,
.pill select{
  border: 1px solid rgba(17,24,39,.10);
  background: rgba(255,255,255,.80);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 750;
  min-width: 120px;
  max-width: 100%;
}
.pill input{ min-width: 160px; }

/* Focus states */
input:focus, select:focus{
  outline: none;
  border-color: rgba(109,140,255,.55);
  box-shadow: 0 0 0 2px rgba(109,140,255,.14);
}

/* Content blocks */
.content{ padding: 14px; }
.hr{
  height: 1px;
  background: rgba(17,24,39,.07);
  margin: 14px 0;
}

.notice{
  padding: 10px 12px;
  border: 1px solid rgba(109,140,255,.22);
  background: rgba(109,140,255,.08);
  border-radius: var(--radius2);
  color: rgba(17,24,39,.86);
  font-weight: 800;
}

/* Tables */
table{
  width: 100%;
  border-collapse: collapse;
}
th, td{
  padding: 12px 14px;
  border-bottom: 1px solid rgba(17,24,39,.06);
  vertical-align: middle;
}
th{
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: rgba(55,65,81,.72);
  font-weight: 950;
}
tbody tr:hover td{
  background: rgba(109,140,255,.06);
}
.right{ text-align: right; }

.sort{ color: rgba(55,65,81,.55); font-weight: 950; margin-left: 6px; }

.num{ text-align: right; font-weight: 950; }
.small{ font-size: 12px; color: rgba(55,65,81,.70); font-weight: 850; }

/* Name row */
.name{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 0;
}
.badge{
  width: 30px;
  height: 30px;
  border-radius: 12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight: 950;
  font-size: 12px;
  color: rgba(17,24,39,.88);
  background:
    radial-gradient(12px 12px at 30% 30%, rgba(255,255,255,.92), rgba(255,255,255,0)),
    linear-gradient(135deg, rgba(109,140,255,.22), rgba(120,209,178,.16));
  border: 1px solid rgba(17,24,39,.08);
  flex: 0 0 auto;
}
.gold-name{ color: var(--gold); }

.wins{ color: var(--win); font-weight: 950; }
.loses{ color: var(--lose); font-weight: 950; }

/* Streak badge */
.streak-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(180,35,44,.25);
  background: rgba(180,35,44,.10);
  color: rgba(180,35,44,.95);
  font-weight: 950;
  font-size: 12px;
  margin-left: 8px;
}

/* Meta KPI bar */
.meta{
  display:flex;
  gap: 10px;
  align-items:center;
  justify-content:flex-start;
  flex-wrap: wrap;
  padding: 12px 14px;
}
.kpi{
  display:inline-flex;
  gap: 8px;
  align-items:baseline;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(17,24,39,.08);
  background: rgba(255,255,255,.60);
  font-weight: 850;
  color: rgba(55,65,81,.72);
}
.kpi b{ color: rgba(17,24,39,.92); }

/* Home: prevent “squeezing” – allow horizontal scroll on narrow desktop */
#playersTable{ min-width: 720px; }
#gameTable{ min-width: 0; }
/* Head tools stack on smaller widths to avoid compression */
@media (max-width: 820px){
  .head{
    align-items: flex-start;
  }
  .head .tools{
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    justify-content: stretch;
  }
  .pill{ width: 100%; }
  .pill input{ width: 100%; min-width: 0; }
  .pill select{ width: 100%; min-width: 0; }
}

/* Fix: game pill not clipped */
.pill{ flex-wrap: wrap; }
.pill select{ flex: 1 1 160px; }
#gameCount{ white-space: nowrap; flex: 0 0 auto; }
@media (max-width: 520px){
  #gameCount{ width: 100%; }
}

/* Mobile: ranking as cards (two-row approach) */
.desktopRow { display: table-row; }
.mobileRow  { display: none; }

@media (max-width: 640px){
  .desktopRow{ display: none; }
  .mobileRow{ display: table-row; }

  #playersTable{ border-collapse: separate; border-spacing: 0 10px; min-width: 0; }
  #playersTable td{ border: 0; padding: 0; }
  #playersTable thead{ display:none; }

  .mCard{
    border: 1px solid var(--border);
    border-radius: var(--radius2);
    background: rgba(255,255,255,.76);
    padding: 12px;
  }
  .mTop{
    display:flex;
    align-items:center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(17,24,39,.06);
    margin-bottom: 10px;
  }
  .mName{
    font-weight: 950;
    line-height: 1.1;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
  }
  .mGrid{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .mStat{
    border: 1px solid rgba(17,24,39,.08);
    background: rgba(17,24,39,.02);
    border-radius: 14px;
    padding: 10px;
    display:grid;
    gap: 2px;
  }
  .mLabel{
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: rgba(55,65,81,.66);
  }
  .mVal{
    font-size: 16px;
    font-weight: 950;
    color: rgba(17,24,39,.92);
  }
  .mVal.wins{ color: var(--win); }
  .mVal.loses{ color: var(--lose); }

  /* Buttons top: nicer wrap */
  .actions .btn{ flex: 1 1 auto; }
}
/* Home – Spiel-Tabelle: beide Spalten ohne Horizontal-Scroll sichtbar */
#gameTable{
  width: 100%;
  table-layout: fixed; /* zwingt Spaltenbreiten, verhindert "wegdrücken" */
}

#gameTable th,
#gameTable td{
  padding: 10px 12px; /* enger als Ranking */
}

#gameTable th:first-child,
#gameTable td:first-child{
  width: 72%;
}

#gameTable th:last-child,
#gameTable td:last-child{
  width: 28%;
}

/* Name sauber umbrechen statt rauslaufen */
#gameTable td:first-child .name{
  min-width: 0;
}
#gameTable td:first-child .name span:last-child{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Auf sehr schmalen Displays noch enger */
@media (max-width: 420px){
  #gameTable th, #gameTable td{ padding: 9px 10px; }
  #gameTable th:first-child, #gameTable td:first-child{ width: 68%; }
  #gameTable th:last-child, #gameTable td:last-child{ width: 32%; }
}
