:root {
  --bg: #eef2f9;
  --bg2: #ffffff;
  --card: #ffffff;
  --card2: #f4f7fc;
  --line: #dde4f0;
  --text: #1b2238;
  --muted: #66718c;
  --accent: #0fb886;
  --accent2: #3b6fff;
  --gold: #f5b820;
  --silver: #b9c2d6;
  --bronze: #d08a3e;
  --danger: #e4484d;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(40,60,110,.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #dbe7ff 0, transparent 55%),
              radial-gradient(900px 500px at -10% 10%, #d7f5ec 0, transparent 50%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.75); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 38px; filter: drop-shadow(0 4px 10px rgba(80,100,160,.25)); }
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: .3px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.who .name { font-weight: 600; color: var(--accent); }

/* Tabs */
.tabs {
  display: flex; gap: 6px; padding: 10px 16px; flex-wrap: wrap;
  position: sticky; top: 71px; z-index: 9;
  background: rgba(255,255,255,.6); backdrop-filter: blur(6px);
}
.tab {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600;
  transition: .15s;
}
.tab:hover { color: var(--text); background: var(--card); }
.tab.active { color: #06231a; background: var(--accent); border-color: var(--accent); }

/* Layout */
main { max-width: 920px; margin: 0 auto; padding: 18px 16px 80px; }
.panel { display: none; animation: fade .25s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: linear-gradient(180deg, var(--card), var(--card2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h2 { margin: 0 0 12px; font-size: 18px; }
h3 { margin: 0 0 10px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { background: rgba(40,60,110,.08); padding: 2px 6px; border-radius: 6px; }

/* Buttons & inputs */
.btn {
  background: var(--accent); color: #06231a; border: none;
  padding: 10px 16px; border-radius: 10px; font-weight: 700; cursor: pointer; font-size: 14px;
  transition: .15s;
}
.btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--card); }
.btn.blue { background: var(--accent2); color: #fff; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 6px 10px; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
input, select {
  background: #fff; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent2); border-color: var(--accent2); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label input, label select { margin-top: 5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.hidden { display: none !important; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0 0; }
.link { color: var(--accent2); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
#betsHint .btn { margin-top: 10px; margin-right: 6px; }

/* Rangliste */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
td.num, th.num { text-align: center; }
.rank-badge { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-weight: 800; background: var(--card2); }
.rank-1 .rank-badge { background: var(--gold); color: #3a2c00; }
.rank-2 .rank-badge { background: var(--silver); color: #2a3150; }
.rank-3 .rank-badge { background: var(--bronze); color: #3a2400; }
.total { font-weight: 800; color: var(--accent); font-size: 16px; }

.point-pills { display: flex; gap: 10px; flex-wrap: wrap; }
.pill { background: var(--card2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 12px; }
.pill b { color: var(--accent); font-size: 18px; }
.pill span { display: block; color: var(--muted); font-size: 12px; }

/* Matches */
.match {
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px;
}
.match.finished { border-color: #2c5; }
.match-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.match-main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.team { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.team.home { text-align: right; justify-content: flex-end; }
.team.away { text-align: left; justify-content: flex-start; }
.flag {
  width: 26px; height: 19px; border-radius: 3px; object-fit: cover;
  box-shadow: 0 1px 3px rgba(40,60,110,.25); flex-shrink: 0; vertical-align: middle;
}
.flag-ph { font-size: 18px; box-shadow: none; }
.score { display: flex; align-items: center; gap: 6px; justify-content: center; min-width: 96px; }
.score input { width: 48px; text-align: center; padding: 8px; font-size: 16px; font-weight: 700; }
.score .colon { color: var(--muted); font-weight: 800; }
.result-chip { font-weight: 800; font-size: 18px; padding: 4px 12px; border-radius: 10px; background: #eef2f9; }
.status { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.status.SCHEDULED { background: #e3effb; color: #2a72c0; }
.status.IN_PLAY { background: #fdf0d8; color: #c5780a; }
.status.FINISHED { background: #def3e6; color: #1a8a52; }
.locked-tag { color: var(--danger); font-size: 11px; }

.bet-line { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.bet-line .lbl { color: var(--muted); font-size: 12px; }
.hit { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.hit.exact { background: var(--gold); color: #3a2c00; }
.hit.diff { background: var(--accent); color: #06231a; }
.hit.tendency { background: var(--accent2); color: #fff; }
.hit.miss { background: #fbe3e4; color: #c0383c; }

.empty { text-align: center; color: var(--muted); padding: 30px; }

/* Mitspieler-Tipps in der Spielkarte */
.tips { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.tips.locked-tips { font-size: 12px; color: var(--muted); }
.tips-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 6px; }
.tip-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tip-chip {
  font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
}
.tip-chip b { color: var(--accent); margin-left: 2px; }
.tip-chip.empty-tip { color: var(--muted); font-style: italic; }
.tip-chip.hit-exact { background: #fff5d6; border-color: var(--gold); }
.tip-chip.hit-diff { background: #d8f6ec; border-color: var(--accent); }
.tip-chip.hit-tendency { background: #e1ebff; border-color: var(--accent2); }
.tip-chip.hit-miss { background: #fbe3e4; border-color: var(--danger); }
.tip-chip.hit-miss b { color: var(--danger); }

/* Phasen-Abschnitte im Spielplan */
.phase {
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px;
  background: var(--card); overflow: hidden;
}
.phase > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; font-weight: 700; font-size: 16px;
  background: linear-gradient(180deg, var(--card2), var(--card));
}
.phase > summary::-webkit-details-marker { display: none; }
.phase > summary::after {
  content: '▸'; color: var(--muted); font-size: 14px; transition: transform .2s; margin-left: auto;
}
.phase[open] > summary::after { transform: rotate(90deg); }
.phase-name { display: flex; align-items: center; gap: 8px; }
.phase-meta { color: var(--muted); font-size: 12px; font-weight: 600;
  background: var(--bg); padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); }
.phase-body { padding: 12px 14px 4px; }
.group-block { margin-bottom: 14px; }
.group-title {
  margin: 4px 0 10px; font-size: 13px; font-weight: 700; color: var(--accent2);
  text-transform: uppercase; letter-spacing: .6px; border-bottom: 1px solid var(--line); padding-bottom: 6px;
}

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: .25s; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--accent); }

/* Dialog */
dialog { border: none; border-radius: var(--radius); padding: 0; background: transparent; }
dialog::backdrop { background: rgba(4,8,20,.6); backdrop-filter: blur(3px); }
.dialog-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: min(420px, 92vw); box-shadow: var(--shadow); }

/* Admin sub-cards */
.admin-section { margin-bottom: 16px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--card2); }
.manual-badge { font-size: 11px; font-weight: 700; color: #8a5a00; background: #fff0cf; border: 1px solid var(--gold); padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.tips-edit-box { margin: -4px 0 10px; }
.tipedit { border: 1px solid var(--accent2); border-radius: 10px; padding: 12px; background: #eef3ff; }
.tipedit-head { font-size: 12px; font-weight: 700; color: var(--accent2); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .4px; }
.tipedit-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.tipedit-name { font-weight: 600; min-width: 120px; }
.tipedit-row input { width: 52px; text-align: center; }
.openrow { padding: 5px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.openrow:last-child { border-bottom: none; }
.bets-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.match.untipped { border-left: 3px solid var(--gold); }
/* Getippte Kachel: dauerhaft dezent grün */
.match.tipped {
  background: linear-gradient(180deg, #e9faf2, #e3f7ee);
  border-color: #aae3c9;
  border-left: 3px solid var(--accent);
}
.match.just-saved { animation: savedflash 1s ease; }
@keyframes savedflash {
  0% { background: #b9f0d8; box-shadow: 0 0 0 2px var(--accent); }
  100% { background: #e6f9f0; box-shadow: none; }
}
.bet-info { transition: color .2s; }
.autosave-hint { color: var(--accent); font-weight: 600; }
.day-divider {
  font-weight: 700; font-size: 13px; color: var(--accent2); margin: 14px 0 8px;
  padding-bottom: 5px; border-bottom: 2px solid var(--accent2); text-transform: capitalize;
}
.day-divider:first-child { margin-top: 2px; }

@media (max-width: 620px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .tabs { top: 70px; }

  /* Rangliste: Detailspalten ausblenden, Tabelle bleibt in der Karte */
  .hide-mobile { display: none; }
  th, td { padding: 9px 6px; font-size: 13px; }

  /* Spielplan UND Tippen: Paarungen nebeneinander (Heim – Mitte – Gast), nur kompakter */
  .match-main { gap: 6px; }
  .team { font-size: 13px; gap: 5px; }
  .score { min-width: 0; }
  .result-chip { font-size: 15px; padding: 4px 8px; }
  .score input { width: 40px; padding: 8px 4px; font-size: 15px; }
  .flag { width: 22px; height: 16px; }
}

/* Verhindert, dass breite Tabellen die Seite sprengen – notfalls innerhalb der Karte scrollbar */
.table-wrap { width: 100%; overflow-x: auto; }
