/* ------------------------------------------------------------------ */
/*  Stalo futbolo turnyras – stiliai                                    */
/* ------------------------------------------------------------------ */

:root {
  --bg:        #0e1116;
  --bg-2:      #151a22;
  --panel:     #1a212b;
  --panel-2:   #212a36;
  --line:      #2a3542;
  --line-2:    #38465a;
  --text:      #e7edf5;
  --muted:     #8d9bad;
  --accent:    #4ea8ff;
  --accent-2:  #1f6feb;
  --win:       #35c98a;
  --lose:      #ef6f6f;
  --warn:      #f0b429;
  --gold:      #f5c451;
  --silver:    #c3ccd8;
  --bronze:    #cd8f52;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Viršutinė juosta ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px;
  background: rgba(14,17,22,.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 650; letter-spacing: -.01em; color: var(--text);
}
.brand:hover { text-decoration: none; opacity: .85; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  font-size: 16px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

main { padding: 22px 20px 40px; max-width: 1500px; margin: 0 auto; }

.footer {
  padding: 18px 20px 30px; text-align: center;
  color: var(--muted); font-size: 13px;
  border-top: 1px solid var(--line);
}

/* ---------- Bendri elementai ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 550;
  cursor: pointer; transition: .12s ease;
  white-space: nowrap;
}
.btn:hover { background: #2a3546; border-color: #46586f; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn-primary:hover { background: #2b7ef5; border-color: #2b7ef5; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-danger { border-color: #63343a; color: #ffb4b4; background: #2a1a1d; }
.btn-danger:hover { background: #3a2226; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=number], textarea {
  width: 100%; padding: 9px 11px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 8px;
  font: inherit; font-size: 14px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent-2); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 190px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.7; }
.checkline { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; font-size: 14px; }
.checkline input { width: 16px; height: 16px; accent-color: var(--accent-2); }

.hint { color: var(--muted); font-size: 13px; }
.error-box { background: #2a1a1d; border: 1px solid #63343a; color: #ffb4b4; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }

h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font-size: 14px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }

/* ---------- Pradžios puslapis ---------- */
.home-grid { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } }

.t-list { display: flex; flex-direction: column; gap: 8px; }
.t-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg-2);
  transition: .12s;
}
.t-item:hover { border-color: var(--line-2); background: var(--panel-2); }
.t-item .name { font-weight: 600; }
.t-item .meta { font-size: 12.5px; color: var(--muted); }

/* ---------- Turnyro antraštė ---------- */
.t-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 14px; margin-bottom: 18px;
}
.t-header .sub { color: var(--muted); font-size: 13.5px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--muted);
}
.pill.ok { color: var(--win); border-color: #23603f; background: #10231a; }
.pill.ref { color: var(--warn); border-color: #6b5216; background: #241d09; }

.champion-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; margin-bottom: 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #2a2410, #1d2431);
  border: 1px solid #6b5216;
}
.champion-banner .cup { font-size: 30px; }
.champion-banner .who { font-size: 20px; font-weight: 700; color: var(--gold); letter-spacing: -.01em; }

/* ---------- Tinklelis ---------- */
.bracket-section { margin-bottom: 26px; }
.bracket-section > h2 { display: flex; align-items: center; gap: 9px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.w { background: var(--accent); }
.dot.l { background: var(--lose); }
.dot.f { background: var(--gold); }

.rounds {
  display: flex; gap: 16px; align-items: stretch;
  overflow-x: auto; padding-bottom: 10px;
}
.round { min-width: 236px; flex: 0 0 236px; display: flex; flex-direction: column; }
.round-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 650; margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.round-body { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; flex: 1; }

.match {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; overflow: hidden;
  transition: .12s;
}
.match.ready { border-color: var(--accent-2); box-shadow: 0 0 0 1px rgba(31,111,235,.3); }
.match.clickable { cursor: pointer; }
.match.clickable:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.match.bye { opacity: .5; }
.match.skipped { opacity: .35; }

.match-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 9px; font-size: 11px; color: var(--muted);
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  letter-spacing: .03em;
}
.match-head .tag { font-weight: 650; }
.match-head .flag { color: var(--accent); font-weight: 650; }

.side {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; font-size: 14px;
}
.side + .side { border-top: 1px solid var(--line); }
.side .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .sc {
  min-width: 26px; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted);
}
.side.winner { background: rgba(53,201,138,.09); }
.side.winner .nm { font-weight: 650; color: #b9f2d8; }
.side.winner .sc { color: var(--win); }
.side.loser .nm { color: var(--muted); }
.side.empty .nm { color: #5b6779; font-style: italic; }
.side .seedno {
  font-size: 10.5px; color: #66748a; font-variant-numeric: tabular-nums;
  min-width: 16px; text-align: center;
  border: 1px solid var(--line); border-radius: 4px; padding: 0 3px;
}
.side.out .nm { text-decoration: line-through; opacity: .6; }
.side.has-role { align-items: flex-start; padding-top: 7px; }
.side.has-role .nm { white-space: normal; }
.side .role {
  display: block; font-size: 9.5px; line-height: 1.35; font-weight: 650;
  color: #71809a; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 1px;
}

.note-card {
  border: 1px dashed var(--line-2); border-radius: 9px;
  padding: 10px 12px; font-size: 12.5px; line-height: 1.45;
  color: var(--text); background: rgba(245,196,81,.06);
}
.note-card.muted { color: var(--muted); background: transparent; }

/* ---------- Uždarymo puslapis ---------- */
.finish { max-width: 1080px; margin: 0 auto; }

.finish-hero {
  text-align: center; padding: 30px 20px 26px; margin-bottom: 8px;
  border-radius: 14px;
  background: radial-gradient(120% 140% at 50% 0%, rgba(245,196,81,.16), rgba(31,111,235,.07) 55%, transparent 80%);
  border: 1px solid #4a4021;
}
.finish-hero .cup { font-size: 44px; line-height: 1; filter: drop-shadow(0 4px 10px rgba(245,196,81,.3)); }
.finish-hero .kicker {
  margin-top: 12px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); font-weight: 650;
}
.finish-hero .champ-name {
  margin: 6px 0 8px; font-size: 40px; line-height: 1.1; letter-spacing: -.03em;
  color: var(--gold); text-wrap: balance;
}
.finish-hero .champ-sub { color: var(--muted); font-size: 14px; max-width: 560px; margin: 0 auto; }

/* --- pjedestalas --- */
.podium {
  display: grid; grid-template-columns: 1fr 1.15fr 1fr;
  align-items: end; gap: 10px; margin: 22px 0 24px;
}
.podium .step { text-align: center; }
.podium .medal { font-size: 24px; }
.podium .who { font-weight: 700; letter-spacing: -.01em; margin-top: 2px; overflow-wrap: anywhere; }
.podium .rec { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.podium .block {
  display: grid; place-items: center;
  border-radius: 10px 10px 0 0; border: 1px solid var(--line-2); border-bottom: none;
  font-size: 26px; font-weight: 800; color: rgba(255,255,255,.28);
}
.podium .p1 .who { font-size: 19px; color: var(--gold); }
.podium .p1 .block { height: 116px; background: linear-gradient(180deg, rgba(245,196,81,.28), rgba(245,196,81,.05)); border-color: #6b5216; }
.podium .p2 .block { height: 84px; background: linear-gradient(180deg, rgba(195,204,216,.22), rgba(195,204,216,.04)); }
.podium .p3 .block { height: 62px; background: linear-gradient(180deg, rgba(205,143,82,.22), rgba(205,143,82,.04)); }
.podium .p2 .who { color: var(--silver); }
.podium .p3 .who { color: var(--bronze); }

.finish-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; align-items: start; }
.finish-col { display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 860px) {
  .finish-grid { grid-template-columns: 1fr; }
  /* siaurame ekrane pjedestalas virsta sąrašu – nugalėtojas viršuje */
  .podium { grid-template-columns: 1fr; gap: 14px; }
  .podium .block { height: 6px !important; border-radius: 99px; border-bottom: 1px solid var(--line-2); }
  .podium .block span { display: none; }
  .podium .p1 { order: 1; } .podium .p2 { order: 2; } .podium .p3 { order: 3; }
}

.stat-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px;
}
.stat.wide { grid-column: 1 / -1; }
.stat .k { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.stat .v { display: block; font-size: 16px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; }
.stat.wide .v { font-size: 14px; font-weight: 600; }

ol.path { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
ol.path li {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px; border-radius: 8px; font-size: 13.5px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-left: 3px solid var(--win);
}
ol.path li.l { border-left-color: var(--lose); }
ol.path .rid { font-size: 11px; color: var(--muted); min-width: 38px; }
ol.path .opp { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ol.path .res { font-variant-numeric: tabular-nums; font-weight: 700; }
ol.path li.l .res { color: var(--lose); }
ol.path li.w .res { color: var(--win); }

.finish-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 24px; }

/* --- konfeti --- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti i {
  position: absolute; top: -14px; width: 8px; height: 13px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: .15; }
}
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } }

/* ---------- Įspėjimas apie pasenusį serverį ---------- */
.stale-bar {
  position: sticky; top: 0; z-index: 40;
  padding: 11px 20px; font-size: 14px; line-height: 1.5;
  background: #3a2226; color: #ffd7d7;
  border-bottom: 1px solid #7a3d45;
}
.stale-bar code {
  background: rgba(0,0,0,.35); padding: 1px 6px; border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
}

/* ---------- Registracija ---------- */
.pill.warn { color: var(--warn); border-color: #6b5216; background: #241d09; }

.reg-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .reg-grid { grid-template-columns: 1fr; } }

.reg-list { display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow-y: auto; }
.reg-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--line);
}
.reg-item.own { border-color: var(--accent-2); background: rgba(31,111,235,.1); }
.reg-item .no {
  min-width: 22px; text-align: center; font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--muted);
}
.reg-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.reg-item .acts { display: flex; gap: 4px; opacity: .75; }
.reg-item:hover .acts { opacity: 1; }

/* ---------- Šoninė juosta ---------- */
.t-body { display: grid; grid-template-columns: minmax(0,1fr) 310px; gap: 22px; align-items: start; }
@media (max-width: 1100px) { .t-body { grid-template-columns: 1fr; } }
.sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 74px; }

table.standings { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.standings th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650; padding: 0 6px 7px; border-bottom: 1px solid var(--line);
}
table.standings td { padding: 6px; border-bottom: 1px solid var(--line); }
table.standings tr:last-child td { border-bottom: none; }
table.standings td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.standings .place { color: var(--muted); font-variant-numeric: tabular-nums; width: 34px; }
table.standings tr.p1 .place, table.standings tr.p1 .nm { color: var(--gold); font-weight: 700; }
table.standings tr.p2 .place, table.standings tr.p2 .nm { color: var(--silver); font-weight: 650; }
table.standings tr.p3 .place, table.standings tr.p3 .nm { color: var(--bronze); font-weight: 650; }
table.standings tr.out td { opacity: .55; }
.life { display: inline-flex; gap: 3px; vertical-align: middle; }
.life i { width: 7px; height: 7px; border-radius: 50%; background: var(--win); display: block; }
.life i.gone { background: #4a5566; }
.life i.dead { background: var(--lose); }

.next-list { display: flex; flex-direction: column; gap: 7px; }
.next-item {
  padding: 8px 10px; border-radius: 8px; background: var(--bg-2);
  border: 1px solid var(--line); font-size: 13.5px; cursor: pointer;
}
.next-item:hover { border-color: var(--accent); }
.next-item .r { font-size: 11px; color: var(--muted); }

.progress-bar { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; margin-top: 8px; }
.progress-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

/* ---------- Modalas ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5,8,12,.65); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 420px;
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 12px; box-shadow: var(--shadow); padding: 20px;
}
.modal h2 { margin-bottom: 4px; }
.score-row {
  display: grid; grid-template-columns: 1fr 74px; gap: 10px; align-items: center;
  padding: 9px 0;
}
.score-row .nm { font-weight: 600; }
.score-row input { text-align: center; font-size: 18px; font-weight: 700; padding: 8px; }
.vs { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: .1em; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Pranešimai ---------- */
.toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 9px 15px; border-radius: 9px; font-size: 14px;
  background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  animation: pop .18s ease;
}
.toast.err { background: #2a1a1d; border-color: #63343a; color: #ffb4b4; }
.toast.ok { background: #10231a; border-color: #23603f; color: #b9f2d8; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Spausdinimas ---------- */
@media print {
  :root { --bg:#fff; --panel:#fff; --bg-2:#fff; --panel-2:#fff; --text:#000; --muted:#555; --line:#bbb; --line-2:#999; }
  html, body { background: #fff; color: #000; font-size: 11px; }
  .topbar, .footer, .sidebar-noprint, .btn, .toast-root, .modal-back, .next-list, .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  .rounds { overflow: visible; flex-wrap: nowrap; gap: 8px; }
  .round { min-width: 0; flex: 1 1 0; }
  .match { break-inside: avoid; border-color: #999; }
  .side.winner { background: #eef7f1 !important; }
  .t-body { grid-template-columns: 1fr; display: block; }
  .sidebar { position: static; }
  .champion-banner { background: #fff8e6; border-color: #c9a227; }
  a { color: #000; }
  .confetti, .finish-actions { display: none !important; }
  .finish-hero { background: #fff8e6 !important; border-color: #c9a227; padding: 18px; }
  .finish-hero .champ-name { color: #000; font-size: 30px; }
  .finish-grid { display: block; }
  .finish-col { display: block; }
  .finish-col .card, .finish-grid .card { break-inside: avoid; margin-bottom: 12px; }
  .podium .block { border-color: #999; background: #f2f2f2 !important; }
  .podium .p1 .who, .podium .p2 .who, .podium .p3 .who { color: #000; }
  .stat { border-color: #bbb; }
  /* medalių spalvos ant balto popieriaus neįskaitomos */
  table.standings tr.p1 .place, table.standings tr.p1 .nm,
  table.standings tr.p2 .place, table.standings tr.p2 .nm,
  table.standings tr.p3 .place, table.standings tr.p3 .nm { color: #000; font-weight: 700; }
  table.standings tr.out td { opacity: 1; }
  ol.path li { border: 1px solid #bbb; border-left: 3px solid #444; }
  ol.path li.w .res, ol.path li.l .res { color: #000; }
}
