:root {
  --bg: #0b0d12;
  --bg2: #12151d;
  --card: #161a24;
  --card2: #1d2230;
  --line: #262c3b;
  --text: #eef1f7;
  --muted: #8b93a7;
  --accent: #ffb020;
  --accent2: #ff7a1a;
  --good: #3ddc97;
  --bad: #ff5d6c;
  --blue: #5aa9ff;
  --violet: #b18cff;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.4; min-height: 100vh; overflow-x: hidden;
  background:
    radial-gradient(800px 400px at 100% -10%, rgba(255,122,26,.10), transparent 60%),
    radial-gradient(600px 400px at -10% 0%, rgba(90,169,255,.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }
.splash { min-height: 80vh; display: grid; place-items: center; font-size: 56px; }

/* ---------- typografia ---------- */
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 14px; }
h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 4px 10px; display: flex; align-items: center; gap: 8px; }
h2 .count { background: var(--card2); color: var(--text); border-radius: 99px; padding: 1px 8px; font-size: 12px; letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center { text-align: center; }
.mt { margin-top: 12px; }

.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.back { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); font-size: 20px; }

/* ---------- karty ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.card.hero { background: linear-gradient(135deg, #1e2333, #161a24); }
.card.tap { transition: transform .15s ease, border-color .2s; cursor: pointer; }
.card.tap:active { transform: scale(.98); border-color: var(--accent); }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; animation: rise .35s both; }
.item.tap:active { transform: scale(.98); }
.list > .item:nth-child(2) { animation-delay: .03s } .list > .item:nth-child(3) { animation-delay: .06s }
.list > .item:nth-child(4) { animation-delay: .09s } .list > .item:nth-child(5) { animation-delay: .12s }
.list > .item:nth-child(n+6) { animation-delay: .15s }

/* ---------- ranking ---------- */
.rank-pos { width: 28px; text-align: center; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.pts { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.pts small { display: block; font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.item.p1 { border-color: rgba(255,176,32,.55); background: linear-gradient(90deg, rgba(255,176,32,.16), var(--card) 60%); }
.item.p2 { border-color: rgba(200,210,230,.35); background: linear-gradient(90deg, rgba(200,210,230,.10), var(--card) 60%); }
.item.p3 { border-color: rgba(205,127,50,.45); background: linear-gradient(90deg, rgba(205,127,50,.13), var(--card) 60%); }
.item.p1 .rank-pos, .item.p1 .pts { color: var(--accent); }
.item.me { outline: 2px solid rgba(90,169,255,.5); outline-offset: -1px; }

/* ---------- awatary ---------- */
.av { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #0b0d12; overflow: hidden; background: var(--accent); }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.sm { width: 28px; height: 28px; font-size: 11px; }
.av.lg { width: 64px; height: 64px; font-size: 22px; }
.av.xl { width: 120px; height: 120px; font-size: 40px; box-shadow: 0 0 0 4px var(--card2), 0 0 0 6px var(--accent); }
.av-edit { position: relative; border: 0; background: none; padding: 0; cursor: pointer; flex: none; border-radius: 50%; transition: transform .15s; }
.av-edit:active { transform: scale(.94); }
.av-edit > span:last-child { position: absolute; right: -4px; bottom: -4px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: var(--accent); box-shadow: 0 0 0 3px var(--card); }

/* ---------- chipy ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--card2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.ekipowa { color: var(--accent); border-color: rgba(255,176,32,.35); background: rgba(255,176,32,.08); }
.chip.mieszana { color: var(--blue); border-color: rgba(90,169,255,.35); background: rgba(90,169,255,.08); }
.chip.randomy { color: var(--violet); border-color: rgba(177,140,255,.35); background: rgba(177,140,255,.08); }
.chip.live { color: var(--good); border-color: rgba(61,220,151,.4); background: rgba(61,220,151,.08); }
.chip.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); animation: pulse 1.4s infinite; }
.chip.vote { color: var(--accent); border-color: rgba(255,176,32,.4); }
.chip.good { color: var(--good); border-color: rgba(61,220,151,.4); }
.chip.bad { color: var(--bad); border-color: rgba(255,93,108,.4); }
.chip.pt { color: #0b0d12; background: var(--accent); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- przyciski ---------- */
.btn { appearance: none; border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 12px; padding: 10px 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .12s ease, background .2s, border-color .2s, opacity .2s; user-select: none; min-height: 42px; }
.btn:active { transform: scale(.94); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #1a1205; border-color: transparent; box-shadow: 0 6px 20px rgba(255,122,26,.25); }
.btn.good { background: rgba(61,220,151,.14); border-color: rgba(61,220,151,.45); color: var(--good); }
.btn.bad { background: rgba(255,93,108,.10); border-color: rgba(255,93,108,.4); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.on { border-color: var(--accent); background: rgba(255,176,32,.14); color: var(--accent); }
.btn.busy { pointer-events: none; opacity: .7; }
.btn.busy::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

.fab { position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(84px + var(--safe-b)); z-index: 20; border-radius: 99px; padding: 14px 20px; font-size: 15px; }

.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg a { text-align: center; }
.seg button, .seg a { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .2s, color .2s; }
.seg button.on, .seg a.on { background: var(--card2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset; }

.toggle { width: 46px; height: 28px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); position: relative; flex: none; cursor: pointer; transition: background .2s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .25s cubic-bezier(.5,1.6,.4,1), background .2s; }
.toggle.on { background: rgba(61,220,151,.25); border-color: rgba(61,220,151,.5); }
.toggle.on::after { transform: translateX(18px); background: var(--good); }

/* ---------- formularze ---------- */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }
.input { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none; min-height: 44px; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 80px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- pojedynki ---------- */
.duel { padding: 12px; }
.duel .vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.duel .side { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; min-width: 0; }
.duel .side .name { font-weight: 700; font-size: 14px; max-width: 100%; }
.duel .x { font-size: 22px; animation: clash 2.4s ease-in-out infinite; }
.vote-btn { width: 100%; }
.vote-btn .n { font-variant-numeric: tabular-nums; opacity: .8; }
.bar { height: 6px; border-radius: 99px; background: var(--card2); overflow: hidden; display: flex; margin-top: 8px; }
.bar i { display: block; height: 100%; transition: width .5s cubic-bezier(.3,1.3,.5,1); }
.bar i.a { background: var(--accent); } .bar i.b { background: var(--blue); }

.cand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.cand { background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; transition: transform .12s, border-color .2s, background .2s; text-align: center; }
.cand:active { transform: scale(.94); }
.cand.on { border-color: var(--accent); background: rgba(255,176,32,.12); }
.cand .nm { font-size: 13px; font-weight: 600; max-width: 100%; }
.cand .vc { font-size: 12px; color: var(--muted); }
.cand.lead .vc { color: var(--accent); font-weight: 700; }

.timeline { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin-top: 12px; }
.timeline .k { color: var(--muted); }
.timeline .past { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(139,147,167,.5); }

.notice { border-radius: 14px; padding: 12px 14px; background: rgba(255,176,32,.08); border: 1px solid rgba(255,176,32,.3); color: #ffd58a; font-size: 14px; }
.notice.blue { background: rgba(90,169,255,.08); border-color: rgba(90,169,255,.3); color: #b6d8ff; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }

.hist { font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.hist:last-child { border-bottom: 0; }
.hist .when { color: var(--muted); font-size: 12px; }
.hist .why { color: #ffd58a; font-size: 12px; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; gap: 4px; padding: 8px 8px calc(8px + var(--safe-b)); background: rgba(11,13,18,.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar a { flex: 1; max-width: 130px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 0; border-radius: 12px; position: relative; transition: color .2s, background .2s; }
.tabbar a span { font-size: 20px; line-height: 1; transition: transform .25s cubic-bezier(.5,1.8,.4,1); }
.tabbar a.on { color: var(--text); background: var(--card); }
.tabbar a.on span { transform: translateY(-2px) scale(1.12); }
.tabbar .dot { position: absolute; top: 4px; right: calc(50% - 18px); width: 9px; height: 9px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--bg); animation: pulse 1.4s infinite; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.55); animation: fade .2s both; }
.sheet { position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + var(--safe-b)); animation: sheetUp .32s cubic-bezier(.2,1.2,.4,1) both; }
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 14px; font-size: 19px; }

/* ---------- toasty / animacje ---------- */
.toasts { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 0; right: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--card2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: toastIn .35s cubic-bezier(.2,1.4,.4,1) both; max-width: 520px; }
.toast.err { border-color: rgba(255,93,108,.5); color: #ffb3bb; }
.toast.ok { border-color: rgba(61,220,151,.45); }
.toast.out { animation: toastOut .25s ease both; }

.particle { position: fixed; z-index: 70; pointer-events: none; font-size: 20px; animation: burst .9s cubic-bezier(.2,.8,.3,1) forwards; }
.plus1 { position: fixed; z-index: 70; pointer-events: none; font-weight: 800; font-size: 22px; color: var(--accent); text-shadow: 0 2px 12px rgba(255,176,32,.6); animation: plus 1s ease-out forwards; }
.pop { animation: pop .4s cubic-bezier(.3,1.8,.5,1); }
.spin { animation: spin 1.2s linear infinite; display: inline-block; }
.view { animation: viewIn .28s ease both; }
.static .item, .static .card { animation: none !important; }
button.item { color: inherit; font: inherit; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes clash { 0%,100% { transform: rotate(0) scale(1); } 45% { transform: rotate(-12deg) scale(1.1); } 55% { transform: rotate(12deg) scale(1.15); } }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.6); opacity: 0; } }
@keyframes plus { 0% { transform: translateY(0) scale(.6); opacity: 0; } 20% { opacity: 1; transform: translateY(-10px) scale(1.15); } 100% { transform: translateY(-60px) scale(1); opacity: 0; } }

/* ---------- logowanie ---------- */
.login { min-height: 78vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 14px; }
.login .logo { font-size: 72px; animation: bounce 2s ease-in-out infinite; }
.login h1 { font-size: 30px; margin: 0; }
.gbtn { background: #fff; color: #1f1f1f; border: 0; border-radius: 99px; padding: 13px 22px; font-weight: 700; display: inline-flex; gap: 10px; align-items: center; cursor: pointer; transition: transform .12s; min-height: 48px; }
.gbtn:active { transform: scale(.95); }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
