:root {
  --bg: #f3f6fb;
  --bg-strong: #eaf0f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-blue: #eef6ff;
  --navy: #061b35;
  --navy-2: #092846;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --gold: #f6b51f;
  --gold-dark: #b77905;
  --green: #16a34a;
  --green-bg: #eafaf0;
  --red: #dc2626;
  --red-bg: #fff1f2;
  --orange: #b45309;
  --text: #102033;
  --muted: #667085;
  --line: #d8e0eb;
  --shadow-sm: 0 10px 24px rgba(6, 27, 53, 0.08);
  --shadow-md: 0 18px 50px rgba(6, 27, 53, 0.13);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Heebo', Arial, sans-serif;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, 0.12), transparent 32rem),
    radial-gradient(circle at 85% 0%, rgba(246, 181, 31, 0.14), transparent 28rem),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 46%, #eef3f9 100%);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(6, 27, 53, 0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(6, 27, 53, 0.025) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.55), transparent 70%);
}

.site-header {
  position: relative;
  isolation: isolate;
  background: linear-gradient(135deg, var(--navy) 0%, #08294b 58%, #0b3764 100%);
  color: white;
  padding: 22px clamp(16px, 3vw, 36px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: nowrap;
  box-shadow: 0 18px 36px rgba(6, 27, 53, 0.22);
  overflow: hidden;
}
.site-header::before {
  content: '';
  position: absolute;
  inset: -120px auto auto 42%;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246, 181, 31, 0.16), transparent 68%);
  z-index: -1;
}
.site-header::after {
  content: '';
  position: absolute;
  left: clamp(16px, 3vw, 36px);
  bottom: 0;
  width: min(260px, 42vw);
  height: 4px;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(90deg, var(--gold), rgba(246, 181, 31, 0));
}
.site-header-left h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 36px);
  letter-spacing: -0.035em;
  line-height: 1.05;
  font-weight: 800;
}
.site-header-left p {
  margin: 8px 0 0;
  opacity: 0.82;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.site-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 18px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.site-logo-link:hover { transform: translateY(-1px); }
.site-logo {
  height: 74px;
  width: auto;
  object-fit: contain;
  border-radius: 18px;
  padding: 6px;
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

.container {
  width: min(1480px, calc(100% - 28px));
  margin: 26px auto 46px;
  padding: 0;
  position: relative;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  padding: 8px;
  border: 1px solid rgba(216, 224, 235, 0.9);
  border-radius: 999px;
  background: rgba(255,255,255,0.86);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  width: fit-content;
  max-width: 100%;
}
.tab {
  position: relative;
  background: transparent;
  border: 0;
  padding: 11px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  color: #334155;
  letter-spacing: .01em;
  box-shadow: none;
}
.tab:hover { background: #eef4ff; color: var(--navy); transform: none; box-shadow: none; }
.tab.active {
  background: linear-gradient(135deg, var(--navy) 0%, #0b3764 100%);
  color: white;
  box-shadow: 0 12px 24px rgba(6, 27, 53, 0.18);
}
.tab.active::after {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 5px;
  height: 3px;
  border-radius: 999px;
  background: var(--gold);
}

.auth-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.78);
  box-shadow: var(--shadow-sm);
}
.auth-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 700;
}
.auth-pill strong { color: var(--navy); }
.auth-pill.logged-in { background: var(--green-bg); border-color: #9be7b4; color: #067a36; }
.auth-pill.logged-out { background: #fff7ed; border-color: #fdba74; color: #9a3412; }

.card {
  background: rgba(255,255,255,0.93);
  border: 1px solid rgba(216, 224, 235, 0.95);
  border-radius: var(--radius);
  padding: clamp(18px, 2vw, 24px);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
  backdrop-filter: blur(10px);
}
.card:hover { box-shadow: 0 14px 34px rgba(6, 27, 53, 0.105); }
.section-tight { margin-bottom: 16px; }
.card h2, .card h3 {
  margin-top: 0;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.card h2 { font-size: clamp(21px, 2vw, 28px); }
.card h3 { font-size: 18px; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
  margin-bottom: 8px;
}
.card-header h2 { margin-bottom: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.grid-5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.full { grid-column: 1 / -1; }

label {
  display: block;
  font-weight: 800;
  margin-bottom: 7px;
  color: #24364c;
  font-size: 13px;
  letter-spacing: .01em;
}
input, select, textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  border: 1px solid #cbd6e3;
  border-radius: 12px;
  font-size: 14px;
  background: white;
  color: var(--text);
  font-family: inherit;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(29, 78, 216, .72);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, .12);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
textarea { min-height: 92px; resize: vertical; }

button {
  border: 0;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, var(--navy) 0%, #0b3764 100%);
  color: white;
  box-shadow: 0 10px 20px rgba(6, 27, 53, .16);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease, background-color .16s ease;
  font-family: inherit;
}
button:hover { transform: translateY(-1px); box-shadow: 0 14px 26px rgba(6, 27, 53, .22); filter: brightness(1.04); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.58; cursor: not-allowed; transform: none; filter: none; }
button.secondary {
  background: #eef2f7;
  color: #23344a;
  box-shadow: inset 0 0 0 1px #d5deea;
}
button.secondary:hover { background: #e4ebf5; box-shadow: inset 0 0 0 1px #c8d3e2, 0 10px 22px rgba(6, 27, 53, .1); }
button.warning {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  color: white;
  box-shadow: 0 10px 22px rgba(220,38,38,.22);
}
button.warning:hover { background: linear-gradient(135deg, #991b1b, #c81e1e); }
.toggle-btn { white-space: nowrap; min-width: 140px; text-align: center; }
.actions { display: flex; gap: 12px; margin-top: 17px; flex-wrap: wrap; }

.info {
  position: relative;
  background: linear-gradient(135deg, #eff6ff, #f8fbff);
  border: 1px solid #bfdbfe;
  color: #17437a;
  padding: 13px 15px;
  border-radius: 14px;
  margin-bottom: 16px;
  font-weight: 600;
}
.info::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 999px;
  background: var(--blue);
}
.edit-note {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  padding: 11px 13px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-weight: 700;
}
.muted-note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.hidden { display: none !important; }
.collapsed { display: none; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
table {
  width: 100%;
  min-width: 1000px;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 0;
}
th, td {
  text-align: left;
  padding: 12px 11px;
  border-bottom: 1px solid #e7edf5;
  font-size: 14px;
  vertical-align: middle;
}
th {
  background: linear-gradient(135deg, var(--navy) 0%, #0b3764 100%);
  color: white;
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
th:first-child { border-top-left-radius: 15px; }
th:last-child { border-top-right-radius: 15px; }
td { background: rgba(255,255,255,.92); }
tbody tr:nth-child(even) td { background: #f8fafc; }
tbody tr:hover td { background: #eef5ff; }
tbody tr:last-child td { border-bottom: 0; }
.ranking-table tbody tr:nth-child(even) { background: transparent; }
.ranking-table tbody tr:hover { background: transparent; }
.rank-col, .num-col, .score-col { text-align: right; white-space: nowrap; }
.total-col {
  font-weight: 900;
  color: var(--navy);
  font-size: 15px;
}
.name-col { font-weight: 800; color: var(--navy); }
.club-col { color: #51647c; font-weight: 600; }
.tie-break-col { min-width: 320px; font-size: 12px; color: #53657b; line-height: 1.45; }
.tie-break-line { display: block; white-space: nowrap; }
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 42px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  text-align: center;
  font-weight: 900;
  background: #e5eaf1;
  color: #1f2937;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .04);
}
.rank-first { background: linear-gradient(135deg, #fff3bf, #f6b51f); color: #5b3600; }
.rank-second { background: linear-gradient(135deg, #f1f5f9, #cbd5e1); color: #263445; }
.rank-third { background: linear-gradient(135deg, #ffedd5, #c7823a); color: #4c2604; }
.rank-tied { min-width: 84px; }
.tb-badge, .dq-badge, .dns-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 999px;
  vertical-align: middle;
  white-space: nowrap;
  margin-left: 6px;
  letter-spacing: .03em;
}
.tb-badge { background: #dbeafe; color: #1d4ed8; }
.dq-badge { background: #fee2e2; color: #991b1b; }
.dns-badge { background: #e2e8f0; color: #334155; }

.rank-cell-content {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  max-width: 100%;
}

.rank-cell-content .tb-badge,
.rank-cell-content .dq-badge,
.rank-cell-content .dns-badge {
  margin-left: 0;
}

.summary-box {
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  border: 1px solid #d8e4f2;
  border-radius: 16px;
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
}
.summary-box div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed #d8e4f2;
}
.summary-box div:last-child { border-bottom: 0; }
.summary-box strong {
  display: inline-block;
  min-width: 0;
  color: #34475f;
}
.summary-box span {
  color: var(--navy);
  font-weight: 900;
}
#sumTotal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  padding: 8px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--navy), #0b3764);
  color: white;
  font-size: 25px;
  box-shadow: 0 10px 22px rgba(6,27,53,.20);
}

.public-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--navy) 0%, #0b3764 63%, #114c82 100%);
  color: white;
  min-height: 142px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.public-hero::before {
  content: '◎';
  position: absolute;
  right: 26px;
  top: -42px;
  font-size: 180px;
  line-height: 1;
  opacity: .08;
}
.public-hero h2 { color: white; font-size: clamp(28px, 3vw, 42px); margin-bottom: 6px; }
.public-hero p { margin: 0; opacity: 0.88; font-size: 16px; }
.public-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.public-view-control {
  min-width: 240px;
  flex: 0 1 280px;
}
.public-search-box {
  min-width: min(100%, 320px);
  flex: 1 1 420px;
}
.public-view-control,
.public-search-box,
.public-fullscreen-actions {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.public-search-input-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.public-search-input-row input[type="search"] {
  min-height: 46px;
  padding-left: 42px;
  background-image: linear-gradient(transparent, transparent), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px 50%;
}
.public-search-clear {
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px #d5deea;
}
.public-search-hint {
  margin-top: 7px;
}
.public-toolbar-note {
  margin-top: 8px;
}
.public-fullscreen-actions {
  flex: 0 0 auto;
}
.public-fullscreen-actions button,
.public-search-clear {
  min-height: 46px;
}
.public-toolbar select { min-height: 46px; }
.public-section-target { scroll-margin-top: 20px; }
#public .card:not(.public-hero) > h2::before,
#judge .card > h2::before,
#admin .card > h2::before,
.card-header h2::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  margin-right: 10px;
  vertical-align: middle;
  box-shadow: 0 0 0 5px rgba(246,181,31,.15);
}

#judgeRoundLockInfo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #ecfdf5;
  color: #067a36;
  border-color: #9be7b4;
}
#judgeRoundLockInfo::before {
  content: '';
  position: static;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
}

#scoreForm {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 16px;
  align-items: start;
}
#scoreForm > .grid { grid-column: 1 / -1; }
#scoreForm > .card { grid-column: 1; margin-bottom: 0; }
#scoreForm > .summary-box {
  grid-column: 2;
  grid-row: 2 / span 4;
  position: sticky;
  top: 16px;
}
#scoreForm > .actions,
#scoreForm > .muted-note { grid-column: 1 / -1; }
#scoreForm > .actions button:first-child {
  background: linear-gradient(135deg, #e6a914, var(--gold));
  color: #2f2100;
  box-shadow: 0 12px 24px rgba(246, 181, 31, .26);
}
.shot-input-row { display: flex; align-items: center; gap: 8px; }
.shot-k { display: flex; align-items: center; gap: 5px; white-space: nowrap; font-weight: 800; font-size: 12px; margin: 0; color: #53657b; }
.shot-k input { width: auto; accent-color: var(--gold); }
.shot-cell {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  border: 1px solid #dce5ef;
  border-radius: 14px;
  background: #fbfdff;
}
.shot-cell label:first-child { color: #64748b; margin-bottom: 0; text-align: center; }
.shot-cell select { text-align: center; font-weight: 900; color: var(--navy); }
.comment-box textarea, #roundComment { width: 100%; min-height: 84px; resize: vertical; }

#adminDataMasterToolsCard {
  border-color: rgba(220,38,38,.22);
}
#adminDataMasterToolsCard .info {
  background: linear-gradient(135deg, #fff7ed, #fff1f2);
  border-color: #fed7aa;
  color: #9a3412;
}
#adminDataMasterToolsCard .info::before { background: var(--red); }
#adminRoundLocksCard .table-wrap,
#adminPlayersListCard .table-wrap,
#adminTeamsListCard .table-wrap { margin-top: 8px; }
.toolbar-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 12px;
}
.search-box { margin-top: 8px; min-width: 260px; max-width: 460px; flex: 1; }
.search-box input { width: 100%; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 27, 53, 0.62);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(6px);
}
.modal-backdrop.show { display: flex; }
.modal {
  width: 100%;
  max-width: 430px;
  background: white;
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255,255,255,.6);
}
.modal h3 { margin-top: 0; margin-bottom: 8px; color: var(--navy); }
.modal p { margin-top: 0; color: var(--muted); }
.modal-error {
  background: var(--red-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
  display: none;
  font-weight: 700;
}
.modal-error.show { display: block; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.highlight-flash { animation: highlightFlash 2s ease; }
@keyframes highlightFlash {
  0% { box-shadow: 0 0 0 0 rgba(246, 181, 31, 0.48); background: #fffbeb; }
  100% { box-shadow: var(--shadow-sm); background: white; }
}

body.public-fullscreen {
  background: #071a30;
}
body.public-fullscreen::before { display: none; }
body.public-fullscreen .container { max-width: 100%; width: 100%; padding: 8px 12px; margin: 0 auto; }
body.public-fullscreen .site-header,
body.public-fullscreen .tabs,
body.public-fullscreen .auth-toolbar,
body.public-fullscreen #admin,
body.public-fullscreen #judge { display: none !important; }
body.public-fullscreen #public { display: block !important; }
body.public-fullscreen .card { margin-bottom: 12px; padding: 14px; border-radius: 16px; }
body.public-fullscreen th,
body.public-fullscreen td { padding: 9px 7px; font-size: 14px; }
body.public-fullscreen h2 { margin-bottom: 10px; font-size: 24px; }
body.public-fullscreen .public-hero { padding: 18px; min-height: auto; }
body.public-fullscreen table { min-width: 0; }
body.public-fullscreen .tie-break-col { min-width: 220px; font-size: 11px; }
body.public-fullscreen .rank-badge { min-width: 46px; min-height: 30px; }

@media (min-width: 1180px) {
  #admin:not(.hidden),
  #office:not(.hidden) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
  }

  #admin > .card,
  #office > .card {
    margin-bottom: 0;
  }

  #admin > .card:first-child,
  #adminPlayersListCard,
  #adminTeamsListCard,
  #office > .card:first-child,
  #officePlayersListCard,
  #officeTeamsListCard {
    grid-column: 1 / -1;
  }

  /* Biuro: najpierw dwa wąskie formularze obok siebie, potem listy na całą szerokość. */
  #officePlayerEntryCard { order: 2; }
  #officeTeamEntryCard { order: 3; }
  #officePlayersListCard { order: 4; }
  #officeTeamsListCard { order: 5; }
}

@media (max-width: 1180px) {
  #scoreForm { grid-template-columns: 1fr; }
  #scoreForm > .summary-box { grid-column: 1; grid-row: auto; position: static; }
}

@media (max-width: 1024px) {
  .container { width: min(100% - 20px, 1480px); }
  .grid { grid-template-columns: 1fr; }
  .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-header,
  .toolbar-row,
  .actions,
  .public-toolbar,
  .auth-toolbar,
  .modal-actions { align-items: stretch; }
  .toggle-btn { width: 100%; }
  .search-box { min-width: 0; max-width: none; width: 100%; }
}

@media (max-width: 768px) {
  body { font-size: 15px; }
  .site-header { padding: 16px; }
  .site-header-left h1 { font-size: 24px; line-height: 1.16; }
  .site-header-left p { font-size: 14px; }
  .site-logo { height: 54px; }
  .container { margin: 16px auto 32px; width: min(100% - 16px, 1480px); }
  .tabs { display: grid; grid-template-columns: 1fr; gap: 8px; border-radius: 18px; width: 100%; }
  .tab,
  .auth-toolbar button,
  .actions button,
  .public-toolbar button,
  .modal-actions button,
  button,
  input,
  select,
  textarea { width: 100%; }
  .auth-toolbar,
  .actions,
  .card-header,
  .public-toolbar,
  .toolbar-row,
  .modal-actions { flex-direction: column; }
  .public-view-control,
  .public-search-box,
  .public-fullscreen-actions { width: 100%; flex-basis: auto; }
  .public-search-input-row { flex-direction: column; }
  .public-search-hint { font-size: 12px; }
  .auth-pill { width: 100%; justify-content: center; }
  .card { padding: 16px; border-radius: 16px; }
  .card h2 { font-size: 22px; }
  .card h3 { font-size: 18px; }
  .grid-5 { grid-template-columns: 1fr; gap: 12px; }
  .shot-input-row { align-items: center; }
  .summary-box div { display: grid; grid-template-columns: 1fr auto; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 760px; }
  th, td { padding: 10px 8px; font-size: 13px; }
  .tie-break-col { min-width: 240px; }
  body.public-fullscreen .container { padding: 6px; }
  body.public-fullscreen .card { padding: 10px; }
  body.public-fullscreen h2 { font-size: 18px; }
  body.public-fullscreen th,
  body.public-fullscreen td { font-size: 12px; padding: 6px 5px; }

  /* Mobilny widok publicznych rankingów w formie kart – tylko CSS, bez zmian liczenia. */
  #public .ranking-table,
  #public .ranking-table thead,
  #public .ranking-table tbody,
  #public .ranking-table tr,
  #public .ranking-table td { display: block; }
  #public .ranking-table { min-width: 0; }
  #public .ranking-table thead { display: none; }
  #public .ranking-table tr {
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid #dfe7f1;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(6, 27, 53, .08);
  }
  #public .ranking-table td {
    border: 0;
    background: transparent !important;
    padding: 7px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    text-align: right;
  }
  #public .ranking-table td::before {
    content: '';
    color: #64748b;
    font-weight: 800;
    text-align: left;
  }
  #public .ranking-table td:nth-child(1)::before { content: 'Miejsce'; }
  #public .ranking-table td:nth-child(2)::before { content: 'Nr'; }
  #public .ranking-table td:nth-child(3)::before { content: 'Zawodnik'; }
  #public .ranking-table td:nth-child(4)::before { content: 'Klub'; }
  #public .ranking-table td:nth-child(5)::before { content: 'TS-2 lewa / R1'; }
  #public .ranking-table td:nth-child(6)::before { content: 'TS-2 lewa X / R2'; }
  #public .ranking-table td:nth-child(7)::before { content: 'TS-2 prawa / R3'; }
  #public .ranking-table td:nth-child(8)::before { content: 'TS-2 prawa X / Suma'; }
  #public .ranking-table td:nth-child(9)::before { content: 'Sylwetka'; }
  #public .ranking-table td:nth-child(10)::before { content: 'Sylwetka X'; }
  #public .ranking-table td:nth-child(11)::before { content: 'Suma'; }
  #public .ranking-table td:nth-child(12)::before { content: 'Komentarz'; }
  #public .name-col { font-size: 17px; }
  #public .total-col { font-size: 20px; }
  #public .rank-col { align-items: flex-start; }
  #public .rank-col .rank-cell-content { justify-content: flex-end; }
}

@media (max-width: 768px) {
  .public-fullscreen-actions { display: none !important; }
}

@media (max-width: 480px) {
  .site-header-left h1 { font-size: 21px; }
  .site-header-left p { font-size: 13px; }
  .site-logo { height: 46px; }
  .container { width: min(100% - 12px, 1480px); }
  .card { padding: 14px; }
  .tab { padding: 10px 12px; }
  .modal { padding: 18px; border-radius: 18px; }
  .rank-badge { min-width: 36px; padding: 4px 8px; }
  .tb-badge, .dq-badge, .dns-badge { margin-left: 0; margin-top: 4px; display: inline-flex; }
  table { min-width: 680px; }
}

@media print {
  body { background: white; color: black; }
  .site-header, .tabs, .auth-toolbar, button, .actions, .public-toolbar { display: none !important; }
  .container { width: 100%; margin: 0; }
  .card { box-shadow: none; border: 0; padding: 0; margin-bottom: 18px; }
  .table-wrap { border: 0; overflow: visible; }
  table { min-width: 0; border-collapse: collapse; }
  th { background: #e5e7eb !important; color: #111827 !important; position: static; }
  th, td { border: 1px solid #d1d5db; font-size: 11px; padding: 6px; }
}

/* Fullscreen desktop: pewniejszy przyklejony nagłówek tabeli publicznej.
   Ważne: w trybie fullscreen usuwamy pionowe ograniczenie .table-wrap,
   bo overflow-x:auto potrafi blokować sticky podczas przewijania całej strony. */
@media (min-width: 769px) {
  body.public-fullscreen #public,
  body.public-fullscreen #public .card,
  body.public-fullscreen #public .table-wrap {
    overflow: visible !important;
  }

  body.public-fullscreen #public .ranking-table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
  }

  body.public-fullscreen #public .ranking-table thead {
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  body.public-fullscreen #public .ranking-table thead th {
    position: sticky;
    top: 0;
    z-index: 1001;
    background: #082744 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 0 rgba(6, 27, 53, 0.22), 0 6px 14px rgba(6, 27, 53, 0.10);
  }

  body.public-fullscreen #public .ranking-table thead th:first-child {
    border-top-left-radius: 14px;
  }

  body.public-fullscreen #public .ranking-table thead th:last-child {
    border-top-right-radius: 14px;
  }
}


/* Panel Sędzia: wybór rundy i eksport PDF/CSV w jednej karcie */
.judge-results-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.judge-results-select {
  min-width: 320px;
  max-width: 420px;
  flex: 1;
  align-self: center;
  transform: translateY(-8px);
}

.judge-results-select select {
  min-height: 46px;
}

.judge-export-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  flex: 1 1 640px;
  flex-wrap: wrap;
}

.judge-export-actions button {
  white-space: nowrap;
  min-height: 46px;
}

.judge-results-toolbar-card .judge-export-note {
  margin-top: 12px;
}

@media (max-width: 900px) {
  .judge-results-toolbar {
    align-items: stretch;
  }

  .judge-results-select,
  .judge-export-actions {
    flex: 1 1 100%;
    min-width: 0;
  }

  .judge-export-actions {
    justify-content: stretch;
  }

  .judge-export-actions button {
    flex: 1 1 180px;
  }
}

@media (max-width: 600px) {
  .judge-export-actions button {
    flex: 1 1 100%;
  }
}
.judge-export-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.judge-export-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.judge-export-row button {
  min-width: 110px;
}

@media (max-width: 768px) {
  .judge-export-actions,
  .judge-export-row {
    align-items: stretch;
    width: 100%;
  }

  .judge-export-row {
    flex-direction: column;
  }

  .judge-export-row button {
    width: 100%;
  }
}
#judgePdfExportCard > h2 {
  margin-bottom: 0px;
}
