:root {
  --bg: #fff;
  --surface: #fff;
  --ink: #1a1a1a;
  --muted: #666;
  --line: #d8d8d8;
  --brand: #176b8a;
  --brand-dark: #0f4f66;
  --accent: #d97706;
  --ok: #157a3c;
  --err: #b42318;
  --soft: #f4f6f7;
  --radius: 4px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

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

.wrap { width: min(920px, calc(100% - 1.5rem)); margin: 0 auto; }
.wrap.wide { width: min(1100px, calc(100% - 1.5rem)); }

.site-header {
  border-bottom: 1px solid var(--line);
  background: #fafafa;
}
.site-header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
}
.brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  max-width: min(100%, 28rem);
}
.brand span {
  display: inline;
  color: var(--brand);
  font-weight: 600;
  font-size: 0.86rem;
}
.nav { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; font-size: 0.92rem; }
.nav a { color: var(--muted); font-weight: 600; }
.nav a:hover { color: var(--brand); text-decoration: none; }

.hero {
  padding: 1rem 0 0.75rem;
}
.hero h1 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  line-height: 1.25;
}
.hero p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
}
.tournament-image {
  display: block;
  max-width: 100%;
  max-height: 350px;
  width: auto;
  height: auto;
  margin: 0 0 0.75rem;
  object-fit: contain;
}
.tournament-image.preview {
  max-height: 220px;
  margin-bottom: 0.45rem;
}
.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.grid { display: grid; gap: 0.65rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 720px) {
  .info-grid { grid-template-columns: 1fr; }
}
.info-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  background: var(--soft);
  font-size: 0.92rem;
}
.info-box div + div { margin-top: 0.25rem; }

.tournament-card h2 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.meta { color: var(--muted); font-size: 0.92rem; display: grid; gap: 0.15rem; }
.badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: #e5f2f6;
  color: var(--brand-dark);
  font-size: 0.75rem;
  font-weight: 700;
}

label { display: block; font-weight: 600; margin-bottom: 0.2rem; font-size: 0.86rem; }
input, select, textarea, button { font: inherit; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem;
  background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 0.55rem; }

.rich-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.35rem;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}
.rich-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  min-width: 2rem;
  height: 1.9rem;
  padding: 0 0.45rem;
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}
.rich-btn:hover { border-color: var(--brand); color: var(--brand); }
.rich-surface {
  min-height: 140px;
  max-height: 420px;
  overflow: auto;
  padding: 0.55rem 0.65rem;
  outline: none;
  line-height: 1.45;
}
.rich-surface--short {
  min-height: 72px;
  max-height: 180px;
}
.rich-surface:focus {
  box-shadow: inset 0 0 0 1px var(--brand);
}
.rich-text a {
  color: var(--brand-dark);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid rgba(15, 79, 102, 0.35);
}
.rich-text a:hover {
  color: var(--brand);
  border-bottom-color: var(--brand);
  text-decoration: none;
}
.tournament-card .rich-text a,
.meta .rich-text a {
  display: inline-flex;
  align-items: center;
  margin: 0.15rem 0 0.25rem;
  padding: 0.28rem 0.65rem;
  border: 0;
  border-radius: var(--radius);
  background: #eceff1;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
}
.tournament-card .rich-text a:hover,
.meta .rich-text a:hover {
  background: #dde3e6;
  color: var(--brand-dark);
  text-decoration: none;
}
.rich-text p { margin: 0 0 0.55rem; }
.rich-text p:last-child { margin-bottom: 0; }
.rich-text ul, .rich-text ol { margin: 0 0 0.55rem; padding-left: 1.25rem; }


.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 0;
  border-radius: var(--radius);
  padding: 0.48rem 0.85rem;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #eceff1; color: var(--ink); }
.btn.accent { background: var(--accent); }
.btn.danger { background: var(--err); }
.btn.small { padding: 0.3rem 0.55rem; font-size: 0.85rem; }

.actions { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-top: 0.7rem; }

.flash {
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  margin: 0.75rem 0;
  font-weight: 600;
  font-size: 0.92rem;
}
.flash.success { background: #e8f7ee; color: var(--ok); }
.flash.error { background: #fdecec; color: var(--err); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.35rem 0.35rem; border-bottom: 1px solid #eee; vertical-align: top; }
th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* kompaktowy formularz rejestracji — jak stary layout */
.reg-box {
  max-width: 640px;
}
.reg-box h2 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}
.player-row {
  border: 0;
  border-radius: 0;
  padding: 0;
  margin-bottom: 0.45rem;
  background: transparent;
}
.player-row h3 {
  display: none;
}
.player-line {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
}
.player-line.email-line {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
}
.player-line > select[data-associated-toggle] {
  flex: 0 0 140px;
  width: 140px;
}
.player-fields {
  flex: 1 1 auto;
  min-width: 0;
}
@media (max-width: 560px) {
  .player-line:not(.email-line) {
    flex-wrap: wrap;
  }
  .player-line > select[data-associated-toggle] {
    flex: 1 1 100%;
    width: 100%;
  }
  .player-fields {
    flex: 1 1 calc(100% - 2.2rem);
  }
  .player-line.email-line { grid-template-columns: 1fr; }
}
.player-remove {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 2.15rem;
  width: 1.75rem;
  height: 2.15rem;
  padding: 0;
  margin: 0;
  cursor: pointer;
  flex: 0 0 1.75rem;
  text-align: center;
}
.player-remove:hover {
  color: var(--err);
}
.player-remove:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.cpt-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex: 0 0 auto;
}
.cpt-pick input {
  margin: 0;
  cursor: pointer;
}
.cpt-pick:has(input:checked),
.cpt-pick input:checked + span {
  color: var(--ink);
}
.badge-cpt {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
  vertical-align: middle;
}
.player-line select {
  background: #5b8fa8;
  color: #fff;
  border-color: #5b8fa8;
  font-size: 0.88rem;
  height: 2.15rem;
  line-height: 2.15rem;
  padding: 0 0.55rem;
  box-sizing: border-box;
}
.player-line input[type="text"],
.player-line input[type="email"] {
  height: 2.15rem;
  line-height: 1.2;
  padding: 0 0.55rem;
  box-sizing: border-box;
}
.selected-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
.hints {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  max-height: 180px;
  overflow-y: auto;
}
.hints li button {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #eee;
  background: transparent;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.hints li:last-child button { border-bottom: 0; }
.hints li button:hover { background: #f3f7f9; }
.hints li button:focus {
  background: #e3eef3;
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* gęsta lista uczestników — responsywna */
.participants-list {
  font-size: 0.9rem;
  line-height: 1.35;
}
.participant-head,
.participant-entry {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.25rem 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid #f0f0f0;
  align-items: center;
}
.participant-head {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
  border-bottom-color: var(--line);
  align-items: end;
}
.participant-entry .num,
.participant-head .num {
  font-weight: 700;
  align-self: center;
  line-height: 1.2;
}
.participant-entry .entry-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.15rem;
}
.participant-entry .team-name {
  font-weight: 700;
}
[data-copy-pids] {
  cursor: pointer;
  border-bottom: 1px dotted var(--muted);
}
[data-copy-pids]:hover,
[data-copy-pids]:focus {
  color: var(--brand);
  border-bottom-color: var(--brand);
  outline: none;
}
.copy-flag {
  margin-left: 0.4rem;
  color: var(--ok);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.copy-flag.is-error { color: var(--err); }
.participant-head .cols,
.player-line-item {
  display: grid;
  grid-template-columns: 4.2rem minmax(8rem, 1.2fr) 3rem minmax(4.5rem, 0.8fr) minmax(10rem, 1.6fr);
  gap: 0.4rem;
  align-items: baseline;
  min-width: 0;
}
.col-rank { text-align: center; }
.col-loc { text-align: center; color: var(--muted); }
.col-pid { color: var(--muted); }
.col-club {
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* telefon: imię+nazwisko, WK, okręg; klub gdy mieści się szerokość */
@media (max-width: 720px) {
  .participant-head { display: none; }
  .player-line-item {
    grid-template-columns: minmax(0, 1fr) 2.6rem minmax(3.5rem, 0.7fr);
    gap: 0.25rem 0.45rem;
  }
  .col-pid { display: none; }
  .col-club { display: none; }
  .col-name { font-weight: 600; }
  .col-rank { text-align: center; color: var(--ink); }
  .col-loc { text-align: center; color: var(--muted); font-size: 0.86rem; }
}
@media (min-width: 480px) and (max-width: 720px) {
  .player-line-item {
    grid-template-columns: minmax(0, 1.2fr) 2.6rem minmax(3.5rem, 0.7fr) minmax(0, 1fr);
  }
  .col-club {
    display: block;
    font-size: 0.84rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.site-footer {
  padding: 1.25rem 0 1.75rem;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
  margin-top: 1rem;
}

.muted { color: var(--muted); }
.stack > * + * { margin-top: 0.45rem; }
.desc { font-size: 0.95rem; }
.note-alert { color: var(--err); font-weight: 700; margin: 0.5rem 0; }

.help-doc p { margin: 0 0 0.55rem; }
.help-doc ol,
.help-doc ul { margin: 0 0 0.55rem; padding-left: 1.25rem; }
.help-doc li + li { margin-top: 0.25rem; }
.help-doc ul ul { margin: 0.25rem 0 0; }
