:root {
  --bg: #0f1419;
  --bg2: #161b22;
  --card: #1c2230;
  --line: #2a3140;
  --text: #e6edf3;
  --muted: #8b97a8;
  --accent: #3fb950;
  --accent2: #2f81f7;
  --gold: #e3b341;
  --danger: #f85149;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }
input, button { font-size: 15px; }

/* ---------- AUTH ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(900px 500px at 50% -10%, #1b2333 0%, var(--bg) 60%);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
}
.auth-card h1 { margin: 0 0 18px; text-align: center; font-size: 24px; letter-spacing: .5px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--bg2); padding: 4px; border-radius: 10px; }
.tab { flex: 1; border: none; background: transparent; color: var(--muted); padding: 9px; border-radius: 8px; font-weight: 600; }
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  padding: 12px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text);
}
.auth-form input:focus { outline: none; border-color: var(--accent2); }
.auth-form button {
  margin-top: 4px; padding: 12px; border: none; border-radius: 9px;
  background: var(--accent); color: #06210e; font-weight: 700;
}
.error { color: var(--danger); text-align: center; min-height: 18px; margin: 12px 0 0; font-size: 14px; }

/* ---------- HEADER ---------- */
header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--bg2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: .3px; }
nav { display: flex; gap: 6px; margin-left: 6px; }
.nav-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 8px; font-weight: 600;
}
.nav-btn.active { background: var(--card); color: var(--text); }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 12px; }
#user-name { color: var(--muted); font-size: 14px; }
.ghost { border: 1px solid var(--line); background: transparent; color: var(--text); padding: 7px 12px; border-radius: 8px; }

main { max-width: 760px; margin: 0 auto; padding: 18px; }
h2.section-title { font-size: 17px; margin: 6px 0 16px; color: var(--muted); font-weight: 600; }

/* ---------- MECZE ---------- */
.stage-group { margin-bottom: 22px; }
.stage-head { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 0 10px; padding-left: 2px; }
.match {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
}
.match-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.match-time { font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 700; }
.badge.open { background: rgba(63,185,80,.15); color: var(--accent); }
.badge.locked { background: rgba(139,151,168,.15); color: var(--muted); }
.badge.done { background: rgba(47,129,247,.15); color: var(--accent2); }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.team { font-weight: 600; }
.team.home { text-align: right; }
.team.away { text-align: left; }
.score-inputs { display: flex; align-items: center; gap: 6px; }
.score-inputs input {
  width: 46px; text-align: center; padding: 9px 0; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 16px; font-weight: 700;
}
.score-inputs input:disabled { opacity: .6; }
.colon { color: var(--muted); font-weight: 700; }
.match-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; min-height: 22px; }
.save-btn { border: none; background: var(--accent2); color: #fff; padding: 8px 16px; border-radius: 8px; font-weight: 600; }
.save-btn:disabled { opacity: .4; cursor: default; }
.saved-msg { color: var(--accent); font-size: 13px; }
.result-line { font-size: 13px; color: var(--muted); }
.pts { font-weight: 800; }
.pts.p3 { color: var(--accent); }
.pts.p2 { color: var(--gold); }
.pts.p1 { color: var(--accent2); }
.pts.p0 { color: var(--muted); }
.link-btn { background: none; border: none; color: var(--accent2); font-size: 13px; padding: 0; text-decoration: underline; }

/* ---------- TABELA ---------- */
table.board { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
table.board th, table.board td { padding: 11px 12px; text-align: center; border-bottom: 1px solid var(--line); }
table.board th { background: var(--bg2); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
table.board td.name { text-align: left; font-weight: 600; }
table.board tr:last-child td { border-bottom: none; }
.rank { font-weight: 800; color: var(--muted); }
.rank.r1 { color: var(--gold); }
.total { font-weight: 800; }

/* ---------- ADMIN ---------- */
.admin-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.admin-card h3 { margin: 0 0 12px; font-size: 15px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-card input, .admin-card textarea {
  padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-family: inherit;
}
.admin-card textarea { width: 100%; min-height: 120px; resize: vertical; }
.admin-card button.primary { border: none; background: var(--accent); color: #06210e; padding: 9px 16px; border-radius: 8px; font-weight: 700; }
.admin-match { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.admin-match .am-teams { flex: 1; min-width: 160px; }
.admin-match input.sc { width: 42px; text-align: center; padding: 6px 0; border-radius: 6px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); }
.admin-match button { border: none; border-radius: 6px; padding: 6px 10px; font-weight: 600; }
.admin-match .save { background: var(--accent2); color: #fff; }
.admin-match .del { background: rgba(248,81,73,.15); color: var(--danger); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---------- MODAL ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; max-width: 440px; width: 100%; max-height: 80vh; overflow-y: auto; position: relative; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none; color: var(--muted); font-size: 26px; line-height: 1; }
.modal-card h3 { margin: 0 0 14px; }
.modal-card table { width: 100%; border-collapse: collapse; }
.modal-card td { padding: 7px 4px; border-bottom: 1px solid var(--line); }

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

@media (max-width: 480px) {
  nav { order: 3; width: 100%; margin-left: 0; justify-content: center; }
  .user-box { margin-left: auto; }
}

/* ---------- FLAGI ---------- */
.flag {
  width: 22px; height: auto; border-radius: 3px; vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(255,255,255,.12);
}
.team.home .flag { margin-left: 8px; }
.team.away .flag { margin-right: 8px; }
.admin-match .flag { width: 20px; margin: 0 4px; }

/* ---------- BANER GORNY ---------- */
.hero {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; margin-bottom: 18px; border-radius: var(--radius);
  background: linear-gradient(120deg, #14233f 0%, #1b2b20 100%);
  border: 1px solid var(--line);
}
.hero-emoji { font-size: 34px; line-height: 1; }
.hero-title { font-weight: 800; font-size: 20px; letter-spacing: .3px; }
.hero-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- NAGLOWKI GRUP ---------- */
.group-banner { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.group-badge {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gc); color: #0c0f14; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gc) 25%, transparent);
  flex: 0 0 auto;
}
.group-name { font-weight: 700; font-size: 15px; color: var(--text); }
.group-line {
  flex: 1; height: 2px; border-radius: 2px; opacity: .55;
  background: linear-gradient(90deg, var(--gc), transparent);
}

/* kolorowy pasek grupy z lewej strony karty meczu */
.match { border-left-width: 3px; }

/* ---------- MODAL: naglowek z flagami ---------- */
.modal-teams { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal-teams .flag { width: 24px; }
.modal-teams .vs { color: var(--muted); font-weight: 600; }

/* ---------- WIDOK CHRONOLOGICZNY ---------- */
.day-head {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); font-weight: 700;
  margin: 24px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.day-head:first-of-type { margin-top: 6px; }
.mt-left { display: inline-flex; align-items: center; gap: 8px; }
.group-chip {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px;
  color: var(--gc);
  background: color-mix(in srgb, var(--gc) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--gc) 40%, transparent);
}

/* ---------- GRAFIKI / BRANDING ---------- */
/* tlo ekranu logowania - plakat */
.auth-wrap {
  background-color: #07090d;
  background-image:
    linear-gradient(rgba(8,11,16,.45), rgba(8,11,16,.72)),
    url('img/login-bg.jpg');
  background-position: center, center;
  background-size: cover, contain;
  background-repeat: no-repeat, no-repeat;
}
/* logo w banerze */
.hero-logo {
  width: 58px; height: 58px; border-radius: 12px; object-fit: cover; flex: 0 0 auto;
  box-shadow: 0 2px 10px rgba(0,0,0,.45);
}
/* grafika puli nagrod */
.nagrody-img {
  width: 100%; height: auto; display: block;
  border-radius: var(--radius); border: 1px solid var(--line);
}
/* galeria "nasza ekipa" */
.ekipa {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); gap: 12px;
}
.ekipa-item {
  margin: 0; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.ekipa-item img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; }
.ekipa-item figcaption {
  padding: 7px 8px; font-size: 12px; font-weight: 600; text-align: center; color: var(--muted);
}

/* ---------- WARSTWA AMBIENT (przewijane zdjecia + cytaty) ---------- */
#ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
#app-screen { position: relative; z-index: 1; }
#auth-screen { position: relative; z-index: 2; }
.amb-item {
  position: absolute; left: 0; white-space: nowrap; will-change: transform;
  transform: translateX(110vw); animation: amb-drift linear forwards;
}
@keyframes amb-drift {
  0%   { transform: translateX(110vw) scale(var(--sc,1)); opacity: 0; }
  12%  { opacity: var(--op,.3); }
  88%  { opacity: var(--op,.3); }
  100% { transform: translateX(-150%) scale(var(--sc,1)); opacity: 0; }
}
.amb-photo { --op: .42; }
.amb-photo img {
  width: 124px; height: 158px; object-fit: cover; border-radius: 12px; display: block;
  filter: blur(1px) saturate(1.08);
}
.amb-quote {
  --op: .5;
  font-size: clamp(15px, 2.2vw, 22px); font-weight: 800; color: #c7d2e2;
  background: rgba(20,26,38,.4); border: 1px solid var(--line);
  padding: 8px 16px; border-radius: 22px;
}

/* ---------- LICZNIKI ---------- */
.countdown {
  margin: 30px 0 6px; padding: 18px; text-align: center;
  background: linear-gradient(120deg, #1a2336 0%, #20182b 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.cd-title { font-weight: 700; color: var(--text); margin-bottom: 8px; }
.cd-clock { font-size: 22px; font-weight: 800; letter-spacing: .5px; color: var(--gold); }
.cd-sub { color: var(--muted); font-size: 13px; margin-top: 8px; }
.cd-n { color: #fff; }

/* ---------- NAGRODY: kto co daje ---------- */
.prizes { display: grid; gap: 12px; }
.prize-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.prize-card h3 { margin: 0 0 10px; font-size: 16px; }
.prize-card ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.prize-card li { font-size: 14px; line-height: 1.45; }
.pl-place {
  display: inline-block; min-width: 90px; font-weight: 700;
  color: var(--accent2); margin-right: 8px;
}
.prize-note { margin: 10px 0 0; font-size: 13px; color: var(--gold); line-height: 1.45; }
.wiktor h3 .wr {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--bg2); padding: 2px 8px; border-radius: 20px;
  margin-left: 6px; vertical-align: middle;
}
.wiktor .cd-clock { font-size: 18px; text-align: left; color: var(--accent2); }

/* ---------- SOLIDNE TLO SRODKOWEJ KOLUMNY (obrazki plyna pod/obok) ---------- */
main {
  background: var(--bg);
  box-shadow: 0 0 50px 26px var(--bg);
  position: relative; z-index: 1;
  min-height: calc(100vh - 58px);
}

/* ---------- KTO OBSTAWIL ---------- */
.who {
  margin-top: 11px; padding-top: 10px; border-top: 1px dashed var(--line);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.who-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.who-chip { font-size: 12px; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.who-chip.ok { background: rgba(63,185,80,.16); color: var(--accent); }
.who-chip.no { background: rgba(139,151,168,.10); color: var(--muted); border: 1px dashed var(--line); }

/* ---------- ZMIANA / RESET HASLA ---------- */
.pw-form { display: flex; flex-direction: column; gap: 10px; }
.pw-form input {
  padding: 11px 13px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text);
}
.pw-form button {
  padding: 11px; border: none; border-radius: 9px;
  background: var(--accent); color: #06210e; font-weight: 700;
}
.pw-msg { min-height: 16px; margin: 4px 0 0; font-size: 14px; color: var(--danger); text-align: center; }
.pw-msg.ok { color: var(--accent); }

.admin-user {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.admin-user:last-child { border-bottom: none; }
.au-name { flex: 1; min-width: 150px; font-weight: 600; }
.admin-user .reset-pw {
  border: none; border-radius: 6px; padding: 6px 12px; font-weight: 600;
  background: rgba(227,179,65,.16); color: var(--gold); cursor: pointer;
}
.au-result { font-size: 13px; color: var(--muted); width: 100%; }
.temp-pw { font-family: ui-monospace, "Courier New", monospace; font-size: 16px; color: var(--accent); letter-spacing: 1px; }
