:root {
  --bg: #0f172a;
  --card: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --border: #e5e7eb;
  --primary: #111827;
  --primary-text: #ffffff;
  --soft: #f8fafc;
  --warning-bg: #fff7ed;
  --warning-border: #fdba74;
  --ok-bg: #f0fdf4;
  --ok-border: #86efac;
  --bad-bg: #fef2f2;
  --bad-border: #fca5a5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    linear-gradient(rgba(248, 250, 252, 0.78), rgba(248, 250, 252, 0.88)),
    var(--custom-bg-image, url("assets/background.png")) center center / cover fixed no-repeat;
  color: var(--text);
}

.app-header {
  background: var(--bg);
  color: white;
  padding: 22px 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.app-header h1 {
  margin: 0 0 4px 0;
  font-size: 24px;
}

.app-header p {
  margin: 0;
  color: #cbd5e1;
}

.status-pill {
  background: #334155;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 18px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 14px 0;
}

.tab {
  border: 1px solid var(--border);
  background: white;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: var(--primary);
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  grid-template-columns: minmax(300px, 440px) 1fr;
  gap: 16px;
}

.card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.card h2 {
  margin: 0 0 14px 0;
  font-size: 20px;
}

.card h3 {
  margin: 16px 0 8px 0;
  font-size: 15px;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

label {
  display: block;
  margin: 12px 0 6px;
  font-weight: 650;
}

input, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  background: white;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

button.primary {
  margin-top: 14px;
  background: var(--primary);
  color: var(--primary-text);
  width: 100%;
}

button.inline-primary {
  width: auto;
  flex: 1;
}

button.secondary {
  background: #e5e7eb;
  color: #111827;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}

.list-item strong {
  display: block;
  margin-bottom: 4px;
}

.list-item .meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.event-info {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 14px;
}

.event-info.open {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: #14532d;
}

.event-info.closed {
  background: var(--bad-bg);
  border-color: var(--bad-border);
  color: #7f1d1d;
}

.registration-result {
  border: 1px dashed #94a3b8;
  border-radius: 14px;
  min-height: 250px;
  padding: 14px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.registration-result.active {
  border-style: solid;
  color: var(--text);
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 12px;
}

.qr-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  break-inside: avoid;
}

.qr-card strong {
  display: block;
  margin-bottom: 8px;
}

.qr-code-box {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

.qr-text {
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.station-edit {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.station-edit .row {
  justify-content: center;
}

.station-edit select {
  padding: 8px;
  font-size: 14px;
}

.scanner-box {
  margin-top: 14px;
  border: 1px dashed #94a3b8;
  border-radius: 14px;
  min-height: 250px;
  overflow: hidden;
}

.manual-box {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.selected-player {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--soft);
  color: var(--muted);
}

.selected-player.active {
  color: var(--text);
  border-color: #94a3b8;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.summary-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: var(--soft);
}

.summary-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-box strong {
  display: block;
  font-size: 20px;
  margin-top: 4px;
}

.winner {
  border-color: var(--ok-border);
  background: var(--ok-bg);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
}

th {
  background: #f1f5f9;
}

.small-note {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0 0;
}

.warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  margin-bottom: 14px;
}

.hidden {
  display: none !important;
}

.mt {
  margin-top: 14px;
}

footer {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.public-mode .admin-only,
.public-mode footer {
  display: none !important;
}

.public-mode .tabs {
  display: none !important;
}

@media (max-width: 820px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .summary {
    grid-template-columns: 1fr 1fr;
  }

  .card-title-row {
    flex-direction: column;
  }
}




.wide-secondary {
  margin-top: 10px;
  width: 100%;
}

.setup-mode .tabs,
.setup-mode footer {
  display: none !important;
}



.offline-box {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 14px;
}

.offline-box.pending {
  border-color: #facc15;
  background: #fefce8;
  color: #713f12;
}

.offline-box.ok {
  border-color: var(--ok-border);
  background: var(--ok-bg);
  color: #14532d;
}

.mt-small {
  margin-top: 8px;
}


.excel-table th,
.excel-table td {
  font-size: 13px;
  white-space: nowrap;
}

.qr-mini {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: anywhere;
  max-width: 150px;
  white-space: normal;
}

.class-badge {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
}

.print-title {
  display: none;
}

@media print {
  body {
    background: white;
  }

  .app-header,
  .tabs,
  footer,
  #setupWarning,
  .card-title-row button,
  #registrationsList,
  #adminEventInfo,
  #closeRegistrationBtn,
  #registrationView,
  #eventsView,
  #scanView,
  #rankingView,
  #setupView {
    display: none !important;
  }

  .container {
    padding: 0;
    max-width: none;
  }

  .card {
    box-shadow: none;
    border: 0;
  }

  .view {
    display: none !important;
  }

  .view.active {
    display: block !important;
  }

  .grid {
    display: block;
  }

  .qr-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .print-title {
    display: block;
    font-size: 18px;
    margin-bottom: 10px;
  }

  table {
    min-width: 0;
    font-size: 11px;
  }

  th, td {
    padding: 6px;
  }
}


.judge-login-mode .tabs,
.judge-login-mode footer {
  display: none !important;
}

.pin-error {
  color: #991b1b;
  font-weight: 700;
  margin-top: 8px;
}


.danger-button {
  background: #991b1b !important;
  color: white !important;
}


/* Tło aplikacji:
   Jeśli chcesz własne zdjęcie, podmień plik:
   assets/background.png
   Najlepszy rozmiar: 1920x1080 albo większy.
*/

.app-header {
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.82)),
    var(--custom-bg-image, url("assets/background.png")) center center / cover no-repeat;
}

.card {
  backdrop-filter: blur(8px);
}

.tabs .tab {
  backdrop-filter: blur(6px);
}


.background-preview {
  margin-top: 12px;
  border: 1px dashed #94a3b8;
  border-radius: 14px;
  min-height: 150px;
  padding: 12px;
  display: grid;
  place-items: center;
  text-align: center;
  background: rgba(248, 250, 252, 0.75);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  color: var(--muted);
  overflow: hidden;
}

.background-preview.has-image {
  min-height: 220px;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
}

.consent-box,.manual-add-box{margin-top:14px;border:1px solid var(--border);border-radius:14px;padding:12px;background:rgba(248,250,252,.78)}
.checkbox-label{display:flex;gap:10px;align-items:flex-start;margin:0;font-weight:700}
.checkbox-label input{width:auto;margin-top:4px}
.manual-add-box h3{margin:0 0 8px 0}
.table-action{padding:8px 10px;font-size:13px}

.rodo-note{font-size:12px;color:var(--muted)}
.masked-name{font-weight:800;letter-spacing:.02em}

.sync-ok{background:var(--ok-bg);border-color:var(--ok-border);color:#14532d}.sync-warn{background:#fefce8;border-color:#fde68a;color:#713f12}

textarea{width:100%;border:1px solid var(--border);border-radius:12px;padding:12px;font-size:15px;font-family:inherit;resize:vertical}

.consent-title {
  margin: 18px 0 8px 0;
  font-size: 18px;
  color: var(--text);
}


.version-banner {
  background: #991b1b;
  color: white;
  text-align: center;
  font-weight: 900;
  letter-spacing: .03em;
  padding: 14px 10px;
  font-size: 18px;
}


/* v21 refresh-fix */
.version-banner {
  background: #7f1d1d;
  color: white;
  padding: 10px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 14px;
}

.version-banner button {
  background: white;
  color: #7f1d1d;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  border: 0;
  font-weight: 800;
}

@media print {
  .version-banner {
    display: none !important;
  }
}


/* v22 iPhone hard refresh */
.version-banner {
  background: #7f1d1d;
  color: white;
  padding: 10px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 14px;
  z-index: 9999;
}

.version-banner button,
.version-banner .reset-link {
  background: white;
  color: #7f1d1d;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  border: 0;
  font-weight: 800;
  text-decoration: none;
}

@media print {
  .version-banner {
    display: none !important;
  }
}


/* v23 Safari tabs fix */
.version-banner {
  background: #7f1d1d;
  color: white;
  padding: 10px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 14px;
  z-index: 9999;
}

.version-banner button,
.version-banner .reset-link {
  background: white;
  color: #7f1d1d;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  border: 0;
  font-weight: 800;
  text-decoration: none;
}

@media print {
  .version-banner {
    display: none !important;
  }
}


/* v24 auto refresh */
.auto-version-banner {
  background: #064e3b;
}

.auto-refresh-note {
  font-size: 13px;
  opacity: .95;
}

.version-banner .reset-link {
  background: white;
  color: #064e3b;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  border: 0;
  font-weight: 800;
  text-decoration: none;
}

@media print {
  .version-banner {
    display: none !important;
  }
}


/* v25 - czytelniejsze tło i mniejsza przezroczystość */
body {
  background-color: #e5e7eb !important;
}

body::before {
  opacity: 0.18 !important;
  filter: blur(0px) saturate(0.85) contrast(0.9) !important;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background: rgba(248, 250, 252, 0.84);
}

.card,
.list-item,
.qr-card,
.registration-result,
.event-info,
.selected-player,
.offline-box,
.summary-box {
  background: rgba(255, 255, 255, 0.96) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.card {
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12) !important;
}

input,
select,
textarea {
  background: rgba(255, 255, 255, 0.98) !important;
}

.table-wrap,
table {
  background: rgba(255, 255, 255, 0.98) !important;
}

th {
  background: #e2e8f0 !important;
}

.version-banner {
  background: #064e3b !important;
}

@media print {
  body::before,
  body::after {
    display: none !important;
  }

  .card,
  .list-item,
  .qr-card,
  .registration-result,
  .event-info,
  .selected-player,
  .offline-box,
  .summary-box {
    background: white !important;
    box-shadow: none !important;
  }
}


/* =========================================================
   v26 UI CLEAN — czytelniejszy wygląd jak typowa aplikacja web
   ========================================================= */

:root {
  --bg-clean: #f3f4f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-clean: #dbe3ef;
  --accent: #15803d;
  --accent-hover: #166534;
  --danger: #b91c1c;
  --header: #0f172a;
}

/* Domyślnie panel sędziego jest bez mocnego zdjęcia. */
body {
  background: var(--bg-clean) !important;
  color: var(--text-main) !important;
}

body::before {
  opacity: 0 !important;
  display: none !important;
}

body::after {
  display: none !important;
}

/* Grafika tylko dla ekranu rejestracji/logowania, ale delikatna. */
body.public-mode,
body.judge-login-mode,
body.setup-mode {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(21, 128, 61, 0.76)),
    url("./assets/background.png") center/cover fixed no-repeat !important;
}

body.public-mode::before,
body.judge-login-mode::before,
body.setup-mode::before {
  display: none !important;
}

/* Nagłówek bardziej jak normalna aplikacja webowa */
.app-header {
  background: linear-gradient(135deg, #0f172a, #1e293b) !important;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

.app-header h1 {
  letter-spacing: -0.02em;
}

.status-pill {
  background: rgba(255,255,255,0.14) !important;
  border: 1px solid rgba(255,255,255,0.18);
}

/* Pasek wersji mniej agresywny */
.auto-version-banner {
  background: #065f46 !important;
  color: white !important;
  min-height: 42px;
}

.auto-refresh-note {
  font-size: 13px;
  opacity: .9;
}

.version-banner .reset-link {
  background: rgba(255,255,255,0.96) !important;
  color: #065f46 !important;
}

/* Kontener */
.container {
  max-width: 1240px !important;
  padding: 20px !important;
}

/* Zakładki bardziej czytelne */
.tabs {
  background: #ffffff;
  border: 1px solid var(--border-clean);
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
  margin-bottom: 18px !important;
}

.tab {
  background: transparent !important;
  border: 0 !important;
  color: #334155;
  border-radius: 12px !important;
  padding: 12px 16px !important;
}

.tab:hover {
  background: #f1f5f9 !important;
}

.tab.active {
  background: var(--header) !important;
  color: #ffffff !important;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
}

#judgeLogoutBtn {
  color: #991b1b !important;
}

#judgeLogoutBtn:hover {
  background: #fee2e2 !important;
}

/* Dashboard kafle */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin: 0 0 18px 0;
}

.dashboard-card {
  background: #ffffff;
  border: 1px solid var(--border-clean);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.dashboard-card span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.dashboard-card strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1;
  color: var(--text-main);
}

.dashboard-card small {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Karty bez przezroczystości */
.card,
.list-item,
.qr-card,
.registration-result,
.event-info,
.selected-player,
.offline-box,
.summary-box {
  background: #ffffff !important;
  border: 1px solid var(--border-clean) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06) !important;
}

.card {
  border-radius: 20px !important;
  padding: 18px !important;
}

.card h2 {
  letter-spacing: -0.015em;
}

/* Ekran rejestracji */
.registration-hero-card {
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 22px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.18);
}

.registration-hero-card h2 {
  margin: 0 0 6px;
  font-size: 28px;
}

.registration-hero-card p {
  margin: 0;
  color: #475569;
  font-size: 15px;
}

/* Formularze i przyciski pod telefon */
input,
select,
textarea {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: var(--text-main) !important;
  border-radius: 14px !important;
  min-height: 48px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(22, 163, 74, 0.18);
  border-color: var(--accent) !important;
}

button.primary {
  background: var(--accent) !important;
  color: #ffffff !important;
  min-height: 50px;
  border-radius: 14px !important;
  box-shadow: 0 8px 18px rgba(21, 128, 61, 0.22);
}

button.primary:hover {
  background: var(--accent-hover) !important;
}

button.secondary {
  background: #e2e8f0 !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}

button.secondary:hover {
  background: #cbd5e1 !important;
}

/* Tabele jak w prostej aplikacji biurowej */
.table-wrap {
  background: #ffffff !important;
  border: 1px solid var(--border-clean);
  border-radius: 16px;
  overflow: auto;
}

table {
  background: #ffffff !important;
}

th {
  background: #e2e8f0 !important;
  color: #0f172a !important;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .035em;
}

td {
  background: #ffffff;
}

tr:nth-child(even) td {
  background: #f8fafc;
}

/* QR jako etykiety */
.qr-grid {
  gap: 14px !important;
}

.qr-card {
  border-radius: 16px !important;
  padding: 14px !important;
}

/* Statusy */
.event-info.open {
  background: #ecfdf5 !important;
  border-color: #86efac !important;
}

.event-info.closed {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
}

.offline-box.pending {
  background: #fefce8 !important;
  border-color: #fde68a !important;
}

.offline-box.ok {
  background: #ecfdf5 !important;
  border-color: #bbf7d0 !important;
}

/* Mobile */
@media (max-width: 820px) {
  .container {
    padding: 12px !important;
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tabs {
    border-radius: 14px;
    padding: 6px;
  }

  .tab {
    padding: 11px 13px !important;
  }

  .card {
    padding: 15px !important;
  }

  .registration-hero-card h2 {
    font-size: 23px;
  }
}

@media (max-width: 520px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .app-header h1 {
    font-size: 21px;
  }

  input,
  select,
  textarea,
  button {
    font-size: 16px !important;
  }
}

/* Druk QR i list bez grafiki, bez menu, czysto na białym tle */
@media print {
  body {
    background: white !important;
  }

  body::before,
  body::after,
  .app-header,
  .version-banner,
  .tabs,
  footer,
  #setupWarning,
  #dashboardCards,
  .card-title-row button,
  .station-edit,
  #registrationsList,
  #adminEventInfo,
  #closeRegistrationBtn,
  #registrationView,
  #eventsView,
  #scanView,
  #rankingView,
  #setupView,
  #judgeLoginView,
  #settingsView {
    display: none !important;
  }

  .container {
    padding: 0 !important;
    max-width: none !important;
  }

  .view {
    display: none !important;
  }

  .view.active {
    display: block !important;
  }

  .card,
  .qr-card,
  .table-wrap {
    background: white !important;
    box-shadow: none !important;
    border: 0 !important;
  }

  .qr-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
  }

  .qr-card {
    border: 1px solid #111827 !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-title {
    display: block !important;
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 10px;
  }

  table {
    min-width: 0 !important;
    font-size: 11px !important;
  }

  th, td {
    padding: 6px !important;
    border: 1px solid #111827 !important;
  }
}


/* =========================================================
   v27 PRO UI — dashboard, tryb zawodów, status, scoreboard
   ========================================================= */

.global-sync-status {
  margin: 0 0 18px 0;
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid #dbe3ef;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.global-sync-status strong { font-size: 15px; }
.global-sync-status small { color: #64748b; }
.global-sync-status.online { border-color: #86efac; background: #ecfdf5; }
.global-sync-status.offline { border-color: #fde68a; background: #fefce8; }
.global-sync-status.syncing { border-color: #93c5fd; background: #eff6ff; }
.global-sync-status.error { border-color: #fecaca; background: #fef2f2; }

#dayView .card { border-radius: 24px !important; }
#dayView h2 { font-size: 28px; }
#dayView .summary { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
#dayView button { min-height: 62px; font-size: 18px !important; }

.public-scoreboard {
  background: #0f172a;
  color: white;
  min-height: 70vh;
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 18px 38px rgba(15, 23, 42, .22);
}

.scoreboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.scoreboard-header h2 { color: white; font-size: 34px; margin: 0; }
.scoreboard-header p { color: #cbd5e1; margin: 6px 0 0; }

.scoreboard-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.scoreboard-summary .summary-box {
  background: rgba(255,255,255,.10) !important;
  border: 1px solid rgba(255,255,255,.14) !important;
  color: white;
}

.scoreboard-summary .summary-box span { color: #cbd5e1; }
.scoreboard-summary .summary-box strong { color: white; }

.scoreboard-table-wrap {
  border: 1px solid rgba(255,255,255,.14) !important;
  background: rgba(255,255,255,.08) !important;
}

.scoreboard-table { background: transparent !important; color: white; }
.scoreboard-table th {
  background: rgba(255,255,255,.14) !important;
  color: #e2e8f0 !important;
  font-size: 14px;
}

.scoreboard-table td {
  background: rgba(255,255,255,.04) !important;
  color: white;
  font-size: 22px;
  font-weight: 700;
}

.scoreboard-table tr:nth-child(even) td {
  background: rgba(255,255,255,.08) !important;
}

.start-pass {
  border: 2px solid #0f172a;
  border-radius: 22px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  text-align: center;
}

.start-pass-header {
  border-bottom: 1px solid #dbe3ef;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.start-pass h3 { font-size: 24px; margin: 4px 0; }
.start-pass .start-pass-event {
  color: #64748b;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .06em;
}

.start-pass-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.start-pass-detail {
  background: #f1f5f9;
  border-radius: 14px;
  padding: 10px;
}

.start-pass-detail span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.start-pass-detail strong {
  display: block;
  color: #0f172a;
  font-size: 18px;
}

.qr-print-labels .qr-grid { grid-template-columns: repeat(4, 1fr) !important; }
.qr-print-labels .qr-card { padding: 8px !important; font-size: 11px; }
.qr-print-labels .qr-code-box canvas,
.qr-print-labels .qr-code-box img { width: 90px !important; height: 90px !important; }
.qr-print-cards .qr-grid { grid-template-columns: repeat(3, 1fr) !important; }

.event-logo-preview {
  max-height: 54px;
  max-width: 160px;
  object-fit: contain;
  display: block;
  margin-bottom: 8px;
}

.event-meta-line {
  color: #64748b;
  font-size: 13px;
}

@media (max-width: 820px) {
  .scoreboard-header { display: block; }
  .scoreboard-header h2 { font-size: 26px; }
  .scoreboard-summary { grid-template-columns: 1fr 1fr; }
  .scoreboard-table td { font-size: 16px; }
  #dayView .summary { grid-template-columns: 1fr; }
}

@media print {
  .global-sync-status,
  .scoreboard-tools { display: none !important; }

  .public-scoreboard {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }

  .scoreboard-header h2,
  .scoreboard-header p,
  .scoreboard-table td,
  .scoreboard-table th { color: black !important; }

  .qr-print-labels .qr-grid { grid-template-columns: repeat(4, 1fr) !important; }
  .qr-print-cards .qr-grid { grid-template-columns: repeat(3, 1fr) !important; }
}


/* v28 */
.auto-version-banner {
  background: #1e3a8a !important;
}

.auto-refresh-note {
  font-size: 13px;
  opacity: .95;
}

.version-banner .reset-link {
  background: white !important;
  color: #1e3a8a !important;
}


/* v29 Safari/iPhone tabs hard fix */
.tabs,
.tab {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(21, 128, 61, 0.22);
}

.tab {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.view {
  display: none;
}

.view.active {
  display: block !important;
}

.auto-version-banner {
  background: #1d4ed8 !important;
}


/* v30 — nawigacja jako linki #hash, stabilniejsza na iPhone Safari */
.tabs a.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(21, 128, 61, 0.25);
}

.tabs a.tab:visited {
  color: inherit;
}

.tabs a.tab.active {
  color: #fff !important;
}

.view {
  display: none;
}

.view.active {
  display: block !important;
}

.auto-version-banner {
  background: #7c2d12 !important;
}


/* v31 QNAP LOCAL */
.auto-version-banner {
  background: #164e63 !important;
}

.auto-refresh-note {
  font-size: 13px;
  opacity: .95;
}

.version-banner .reset-link {
  background: white !important;
  color: #164e63 !important;
}


/* v32 — BEZ ZAKŁADEK: panel sędziego jako jedna przewijana strona */
.no-tabs-note {
  background: #ecfeff;
  border: 1px solid #67e8f9;
  color: #164e63;
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
}

.jump-menu {
  position: sticky;
  top: 0;
  z-index: 50;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.jump-menu a.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(20, 184, 166, 0.25);
}

body.judge-panel-mode .view {
  display: block !important;
  margin-bottom: 24px;
  scroll-margin-top: 120px;
}

body.judge-panel-mode #setupView,
body.judge-panel-mode #judgeLoginView,
body.judge-panel-mode #playerPortalView,
body.judge-panel-mode #registrationView {
  display: none !important;
}

body.public-mode .view,
body.player-portal-mode .view,
body.scoreboard-mode .view,
body.setup-mode .view,
body.judge-login-mode .view {
  display: none !important;
}

body.public-mode #registrationView,
body.player-portal-mode #playerPortalView,
body.scoreboard-mode #publicScoreboardView,
body.setup-mode #setupView,
body.judge-login-mode #judgeLoginView {
  display: block !important;
}

body.judge-panel-mode .view::before {
  display: block;
  font-weight: 900;
  color: #0f172a;
  margin: 4px 0 8px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

body.judge-panel-mode #eventsView::before { content: "Zawody i rejestracja"; }
body.judge-panel-mode #playersView::before { content: "Lista zawodników"; }
body.judge-panel-mode #dayView::before { content: "Tryb zawodów"; }
body.judge-panel-mode #scanView::before { content: "Skanowanie i wynik"; }
body.judge-panel-mode #rankingView::before { content: "Ranking"; }
body.judge-panel-mode #publicScoreboardView::before { content: "Tablica publiczna"; }
body.judge-panel-mode #qrCodesView::before { content: "Kody QR"; }
body.judge-panel-mode #summaryView::before { content: "Podsumowanie"; }
body.judge-panel-mode #syncView::before { content: "Synchronizacja offline"; }
body.judge-panel-mode #settingsView::before { content: "Ustawienia"; }

.auto-version-banner { background: #0f766e !important; }

@media (max-width: 820px) {
  .jump-menu {
    border-radius: 14px;
    padding: 8px;
  }
  .jump-menu a.tab {
    min-width: max-content;
  }
}


/* v33 — nawigacja mobilna przez natywny select */
.mobile-section-nav {
  display: none;
  background: #ffffff;
  border: 1px solid #bae6fd;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.mobile-section-nav label {
  display: block;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 8px;
}

.mobile-section-nav select {
  width: 100%;
  min-height: 52px;
  font-size: 17px !important;
  font-weight: 800;
  background: #ffffff !important;
  color: #0f172a !important;
}

.jump-menu a.tab {
  pointer-events: auto !important;
  touch-action: manipulation;
}

body.judge-panel-mode .view {
  display: block !important;
  scroll-margin-top: 145px;
}

.auto-version-banner {
  background: #155e75 !important;
}

@media (max-width: 820px) {
  .mobile-section-nav {
    display: block;
    position: sticky;
    top: 0;
    z-index: 80;
  }

  .jump-menu {
    position: static !important;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .jump-menu a.tab {
    min-width: max-content;
    font-size: 13px !important;
    padding: 10px 12px !important;
  }
}


/* v34 — twarda poprawka panelu sędziego po odświeżeniu */
body.judge-panel-mode .view {
  display: block !important;
  margin-bottom: 24px;
  scroll-margin-top: 145px;
}

body.judge-panel-mode #setupView,
body.judge-panel-mode #judgeLoginView,
body.judge-panel-mode #playerPortalView,
body.judge-panel-mode #registrationView {
  display: none !important;
}

body.judge-login-mode .view {
  display: none !important;
}

body.judge-login-mode #judgeLoginView {
  display: block !important;
}

body.setup-mode .view {
  display: none !important;
}

body.setup-mode #setupView {
  display: block !important;
}

body.public-mode .view {
  display: none !important;
}

body.public-mode #registrationView {
  display: block !important;
}

body.player-portal-mode .view {
  display: none !important;
}

body.player-portal-mode #playerPortalView {
  display: block !important;
}

body.scoreboard-mode .view {
  display: none !important;
}

body.scoreboard-mode #publicScoreboardView {
  display: block !important;
}

.mobile-section-nav {
  display: none;
  background: #ffffff;
  border: 1px solid #bae6fd;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.mobile-section-nav label {
  display: block;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 8px;
}

.mobile-section-nav select {
  width: 100%;
  min-height: 52px;
  font-size: 17px !important;
  font-weight: 800;
}

.auto-version-banner {
  background: #166534 !important;
}

@media (max-width: 820px) {
  .mobile-section-nav {
    display: block;
    position: sticky;
    top: 0;
    z-index: 80;
  }
}


/* =========================================================
   v35 — panel sędziego przez jedną listę rozwijaną
   ========================================================= */

.section-select-panel,
.mobile-section-nav {
  display: block !important;
  background: #ffffff;
  border: 1px solid #bae6fd;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  position: sticky;
  top: 0;
  z-index: 90;
}

.section-select-panel label,
.mobile-section-nav label {
  display: block;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 8px;
  font-size: 14px;
}

.section-select-panel select,
.mobile-section-nav select {
  width: 100%;
  min-height: 54px;
  font-size: 17px !important;
  font-weight: 800;
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #94a3b8 !important;
  border-radius: 14px !important;
}

/* Ukrywamy stare poziome zakładki w panelu sędziego. */
body.judge-panel-mode .jump-menu,
body.judge-panel-mode nav.tabs {
  display: none !important;
}

/* W panelu sędziego pokazujemy tylko wybraną sekcję. */
body.judge-panel-mode .view {
  display: none !important;
}

body.judge-panel-mode .view.judge-section-active {
  display: block !important;
  margin-bottom: 24px;
}

/* Ekrany techniczne i publiczne poza panelem. */
body.judge-panel-mode #setupView,
body.judge-panel-mode #judgeLoginView,
body.judge-panel-mode #playerPortalView,
body.judge-panel-mode #registrationView {
  display: none !important;
}

/* Tytuł aktualnej sekcji */
body.judge-panel-mode .view.judge-section-active::before {
  display: block;
  font-weight: 900;
  color: #0f172a;
  margin: 4px 0 10px;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

body.judge-panel-mode #eventsView.judge-section-active::before { content: "Zawody i rejestracja"; }
body.judge-panel-mode #playersView.judge-section-active::before { content: "Lista startowa / zawodnicy"; }
body.judge-panel-mode #dayView.judge-section-active::before { content: "Tryb zawodów"; }
body.judge-panel-mode #scanView.judge-section-active::before { content: "Skanowanie i wynik"; }
body.judge-panel-mode #rankingView.judge-section-active::before { content: "Ranking"; }
body.judge-panel-mode #publicScoreboardView.judge-section-active::before { content: "Tablica publiczna"; }
body.judge-panel-mode #qrCodesView.judge-section-active::before { content: "Kody QR"; }
body.judge-panel-mode #summaryView.judge-section-active::before { content: "Podsumowanie"; }
body.judge-panel-mode #syncView.judge-section-active::before { content: "Synchronizacja offline"; }
body.judge-panel-mode #settingsView.judge-section-active::before { content: "Ustawienia"; }

.auto-version-banner {
  background: #6d28d9 !important;
}

@media (max-width: 820px) {
  .section-select-panel,
  .mobile-section-nav {
    border-radius: 14px;
    padding: 12px;
  }
}


/* v36 — lista rozwijana wymuszona, bez admin-only */
#judgeSectionDropdownPanel {
  display: none;
}

body.judge-panel-mode #judgeSectionDropdownPanel {
  display: block !important;
  background: #ffffff !important;
  border: 2px solid #2563eb !important;
  border-radius: 18px !important;
  padding: 14px !important;
  margin: 0 0 16px 0 !important;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12) !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 9999 !important;
}

#judgeSectionDropdownPanel label {
  display: block !important;
  font-weight: 900 !important;
  color: #0f172a !important;
  margin-bottom: 8px !important;
  font-size: 14px !important;
}

#judgeSectionSelect {
  display: block !important;
  width: 100% !important;
  min-height: 56px !important;
  font-size: 18px !important;
  font-weight: 900 !important;
  background: #ffffff !important;
  color: #0f172a !important;
  border: 2px solid #94a3b8 !important;
  border-radius: 14px !important;
  padding: 0 12px !important;
}

/* W panelu sędziego pokazujemy tylko wybrany ekran */
body.judge-panel-mode .view {
  display: none !important;
}

body.judge-panel-mode .view.judge-section-active {
  display: block !important;
}

/* Ukryj stare zakładki w panelu */
body.judge-panel-mode nav.tabs,
body.judge-panel-mode .jump-menu,
body.judge-panel-mode .tabs {
  display: none !important;
}

.auto-version-banner {
  background: #1d4ed8 !important;
}


/* =========================================================
   v37 — dashboard i pasek online tylko w "Zawody i rejestracja"
   ========================================================= */

/* Domyślnie w panelu sędziego ukrywamy dashboard i pasek synchronizacji. */
body.judge-panel-mode #dashboardCards,
body.judge-panel-mode #globalSyncStatus {
  display: none !important;
}

/* Pokazujemy je tylko na ekranie eventsView. */
body.judge-panel-mode[data-current-section="eventsView"] #dashboardCards {
  display: grid !important;
}

body.judge-panel-mode[data-current-section="eventsView"] #globalSyncStatus {
  display: flex !important;
}

/* Twarde wymuszenie: widoczna jest tylko wybrana sekcja. */
body.judge-panel-mode .view {
  display: none !important;
}

body.judge-panel-mode .view.judge-section-active {
  display: block !important;
}

/* Nie pokazuj rejestracji publicznej w panelu sędziego. */
body.judge-panel-mode #registrationView,
body.judge-panel-mode #judgeLoginView,
body.judge-panel-mode #setupView,
body.judge-panel-mode #playerPortalView {
  display: none !important;
}

/* Lista wyboru zawsze widoczna w panelu. */
body.judge-panel-mode #judgeSectionDropdownPanel {
  display: block !important;
}

/* Poziome stare zakładki schowane, zostaje tylko lista rozwijana. */
body.judge-panel-mode nav.tabs,
body.judge-panel-mode .tabs,
body.judge-panel-mode .jump-menu {
  display: none !important;
}

.auto-version-banner {
  background: #065f46 !important;
}


/* v38 — klasy tylko przy tworzeniu zawodów */
#eventClassesInput {
  min-height: 150px;
}

body.judge-panel-mode #customClassesInput,
body.judge-panel-mode #saveClassesBtn,
body.judge-panel-mode #resetClassesBtn {
  display: none !important;
}

.auto-version-banner {
  background: #0f766e !important;
}


/* v40 — portal zawodnika */
.portal-link-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #bae6fd;
  border-radius: 14px;
  background: #f0f9ff;
  word-break: break-all;
  font-size: 14px;
}

.portal-link-box strong {
  display: block;
  margin-bottom: 6px;
  color: #0f172a;
}

.auto-version-banner {
  background: #075985 !important;
}


/* v41 — Cloudflare Direct Upload, bez Pages Functions */
.auto-version-banner {
  background: #1e40af !important;
}
