/* MatchGrid system — Eightsy-inspired: felt green, gold, dark club */
:root {
  --felt: #0a5c3a;
  --felt-deep: #063d27;
  --felt-dark: #042818;
  --ink: #0c0a08;
  --bg: #0a5c3a;
  --panel: #16110c;
  --panel2: #211a13;
  --line: #3d3223;
  --text: #f2ece1;
  --muted: #b8a989;
  --green: #2e7d4f;
  --green2: #3fa568;
  --accent: #c9a227;
  --gold: #c9a227;
  --gold-soft: #e0c35a;
  --red: #c0392b;
  --blue: #4a7dbd;
  --cream: #f7f1e4;
  --font: "Barlow", system-ui, sans-serif;
  --display: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(10, 92, 58, .45), transparent 60%),
    radial-gradient(ellipse 40% 30% at 90% 100%, rgba(201, 162, 39, .08), transparent 55%),
    linear-gradient(165deg, #041a10 0%, var(--ink) 45%, #120e0a 100%);
  background-attachment: fixed;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  opacity: .02;
  background-size: 180px 180px;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hidden { display: none !important; }

.ac { position: relative; }
.ac-list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: none;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
  border-radius: 0 0 10px 10px;
}
.ac-item {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-item:hover { background: var(--panel2); }
.ac-empty { padding: 8px 10px; color: var(--muted); }
.p-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel2);
}
.p-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 10px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.p-item:last-child { border-bottom: none; }
.p-item:hover { background: var(--panel); }
.p-item .sub { font-size: 12px; }
.p-item input[type="checkbox"] { width: auto; margin: 0; }

.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input[type="checkbox"] { width: auto; margin: 0; flex-shrink: 0; }
.check-row .sub { font-weight: 400; }

header#topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  background: rgba(12, 10, 8, .9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(201, 162, 39, .18);
  box-shadow: 0 1px 0 rgba(201, 162, 39, .12);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  height: 34px;
  width: auto;
  filter: drop-shadow(0 3px 10px rgba(201, 162, 39, .35));
}
.brand-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--cream);
}
.brand-name span { color: var(--gold); }

#topbar nav { display: flex; gap: 8px; flex: 1; }

.nav-btn, .ghost, .btn, button.primary, button.danger, button.ghost {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  transition: filter .15s, transform .05s, background .15s;
}
.nav-btn {
  background: transparent;
  color: var(--text);
  padding: 9px 16px;
  font-weight: 600;
}
.nav-btn:hover { background: rgba(255,255,255,.05); color: var(--cream); }
.nav-btn.active { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #1a1405; font-weight: 700; }

.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.role-badge {
  font-size: 11px; padding: 2px 10px; border-radius: 999px;
  background: var(--green); color: #fff; font-weight: 700; letter-spacing: .04em;
}
.role-badge.admin { background: var(--accent); color: #1a1405; }

/* language switcher (topbar) */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: background .15s, transform .1s;
}
.lang-btn svg {
  display: block;
  width: 22px;
  height: 15px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28), 0 1px 3px rgba(0,0,0,.5);
}
.lang-btn:hover { transform: scale(1.1); }
.lang-btn.active { background: rgba(201, 162, 39, .35); box-shadow: 0 0 0 1px var(--gold); }

main#app { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* per-club instance branding */
.club-badge { text-align: center; margin: -8px 0 10px; }
.club-badge img {
  max-height: 130px;
  max-width: 240px;
  object-fit: contain;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .35));
}
.club-name {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 10px;
  color: var(--cream);
}
.auth-powered { margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.auth-lang {
  display: flex;
  justify-content: flex-end;
  margin: -6px 0 6px;
}
.auth-powered a { color: var(--gold); text-decoration: none; font-weight: 600; }
.auth-powered a:hover { text-decoration: underline; }
.site-footer {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid rgba(201, 162, 39, .15);
}
.site-footer a { color: var(--gold); text-decoration: none; font-weight: 600; }
.site-footer a:hover { text-decoration: underline; }

h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 20px; margin: 20px 0 10px; }
h3 {
  font-size: 16px;
  margin: 14px 0 8px;
  color: var(--green2);
  font-family: var(--display);
  font-size: 1.2rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.sub { color: var(--muted); font-size: 13px; }

.btn {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #1a1405;
  padding: 9px 18px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(201, 162, 39, .22);
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn.outline { background: transparent; border: 1px solid rgba(201, 162, 39, .5); color: var(--gold-soft); box-shadow: none; }
.btn.outline:hover { background: rgba(201, 162, 39, .12); }
.btn.secondary { background: var(--green); color: #fff; box-shadow: 0 6px 18px rgba(10, 92, 58, .3); }
.danger { background: var(--red); color: #fff; padding: 9px 16px; border-radius: 999px; border: none; font-weight: 700; }
.danger:hover { filter: brightness(1.1); }
.ghost { background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 999px; }
.ghost:hover { color: var(--cream); background: rgba(255,255,255,.05); }

.card {
  background: linear-gradient(165deg, #1e1710, #14100c);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 16px; }

.grid { display: grid; gap: 12px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }

.tournament-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(165deg, #1e1710, #14100c);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .2s, transform .2s;
}
.tournament-row:hover { border-color: rgba(201, 162, 39, .5); transform: translateY(-2px); }
.tournament-row .name { font-weight: 700; font-size: 15px; }
.cycle-head {
  margin: 18px 0 8px;
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gold);
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(201, 162, 39, .25);
}
.cycle-head:first-child { margin-top: 0; }
.badges { display: flex; gap: 8px; align-items: center; }
.badge { font-size: 11px; padding: 3px 10px; border-radius: 999px; background: var(--panel2); color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.badge.draft { background: #4a3d10; color: #f0d060; }
.badge.active { background: #12382a; color: #7fe0ae; }
.badge.completed { background: var(--green); color: #fff; }
.badge.single { background: var(--blue); color: #fff; }
.badge.double { background: #6d4aa0; color: #fff; }
.badge.group { background: #a05a2a; color: #fff; }
.badge.admin-only { background: var(--accent); color: #1a1405; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.tbl tr:hover td { background: rgba(255,255,255,.02); }

input, select {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 162, 39, .12); }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.seed-input { width: 70px; padding: 6px 8px; }
.cap-q { font-size: 18px; font-weight: 700; padding: 8px 0; white-space: nowrap; }

/* bracket */
.bracket {
  display: flex;
  gap: 32px;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: flex-start;
}
.bgroup { display: flex; flex-direction: column; gap: 10px; }
.col-title {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.round-heads { display: flex; padding-bottom: 4px; }
.round-heads .rh {
  width: 210px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  text-align: center;
  flex-shrink: 0;
}
.round-heads .rh-abs {
  position: absolute;
  top: 0;
  width: 210px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  text-align: center;
}
.bracket-body { position: relative; }
.bracket-body svg.connectors { position: absolute; inset: 0; pointer-events: none; }
.bracket-body svg.connectors path {
  fill: none;
  stroke: var(--green);
  stroke-width: 1.6;
  opacity: .55;
}
.bracket-body .match .slot { padding: 5px 10px; font-size: 12.5px; }
.bracket-body .match .actions { min-height: 28px; }
.finals { display: flex; flex-direction: column; gap: 14px; }

.bracket .col { display: flex; flex-direction: column; gap: 8px; min-width: 210px; flex-shrink: 0; }
.bracket .col-head { text-align: center; font-size: 12px; color: var(--muted); padding: 4px; border-bottom: 1px solid var(--line); }
.match {
  background: linear-gradient(160deg, #241c14, #15100c);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.match-wrap {
  position: absolute;
  width: 210px;
  transform: translateY(-50%);
}
.match-wrap .match { width: 100%; }
.match-letter {
  position: absolute;
  top: -16px;
  left: 2px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  opacity: .9;
  letter-spacing: .5px;
}
.loser-note {
  position: absolute;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  padding-left: 2px;
}
.match .slot { position: relative; display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; font-size: 13px; border-bottom: 1px solid rgba(0,0,0,.25); }
.match .slot:last-child { border-bottom: none; }
.match-game {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  padding: 2px 0;
  border-bottom: 1px solid rgba(0,0,0,.25);
  background: rgba(255,255,255,.04);
  letter-spacing: .5px;
}
.match-loser {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  padding: 2px 0;
  border-top: 1px solid rgba(0,0,0,.25);
  background: rgba(255,255,255,.04);
  letter-spacing: .5px;
}
.match-half {
  position: absolute;
  left: -15px;
  top: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  background: linear-gradient(160deg, #241c14, #15100c);
  border: 1px solid var(--line);
  border-radius: 4px 0 0 4px;
  box-sizing: border-box;
  z-index: 1;
}
.match .slot.winner { background: rgba(62,165,104,.22); color: #b7f0cf; font-weight: 700; }
.match .slot .s-name { line-height: 1.3; }
.match .slot .score { font-weight: 700; }
.match .slot .score.win { color: #7fe0ae; }
.match .slot .score.lose { color: var(--muted); }
.match .slot.bye { color: var(--muted); font-style: italic; }
.match .slot .partner { font-size: 13px; color: var(--text); font-weight: 400; }
.match .actions { display: flex; gap: 6px; padding: 6px; }
.match .actions .btn { flex: 1; }

.match.pending-match { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 20px rgba(201, 162, 39, .15); }

/* groups */
.groups-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.groups-wrap > .card { min-width: 0; }
.multi-cfg { display: grid; grid-template-columns: 46px minmax(46px, 1fr) minmax(0, 1.3fr) minmax(46px, 1fr) minmax(46px, 1fr); gap: 6px 6px; margin-top: 6px; align-items: center; }
.multi-cfg .head { color: var(--muted); font-size: 11px; font-weight: 600; }
.multi-cfg .multi-label { font-weight: 700; }
.multi-cfg input[type="number"] { width: 100%; }
.multi-cfg select { min-width: 0; }
.draft-groups { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.draft-groups .card { width: 100%; }
.draft-groups-members { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.draft-groups-members .roster-item { width: 100%; }
.standings .pos { color: var(--muted); }
.standings .qualified { color: #7fe0ae; font-weight: 700; }
.standings .qstar { color: var(--accent); }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: linear-gradient(165deg, #1e1710, #14100c);
  border: 1px solid rgba(201, 162, 39, .3);
  border-radius: 16px;
  padding: 22px;
  width: min(480px, 92vw);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.modal h3 { margin-top: 0; }
.modal .row { display: flex; gap: 12px; align-items: flex-end; }
.score-input {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  width: 100%;
}
.score-col { text-align: center; flex: 1; }
.score-col .pname { font-size: 13px; margin-bottom: 6px; min-height: 36px; }
.modal .hint { color: var(--muted); font-size: 12px; margin-top: 10px; }
.break-row { margin-top: 12px; }
.break-input {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  width: 100%;
}
.break-row .pname.sub { font-size: 11px; }

.brk { color: var(--accent); }
.brks { white-space: nowrap; }
.brk-list { white-space: nowrap; }
.brk-list b { color: var(--accent); margin: 0 2px; }
.brk-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.brk-chip {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.brk-chip b { color: var(--accent); }

/* login */
.auth-wrap { max-width: 440px; margin: 8vh auto; }
.auth-card {
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(10, 92, 58, .35), transparent 55%),
    linear-gradient(165deg, #1a2418, #120e0a 60%, #1a150e);
  border: 1px solid rgba(201, 162, 39, .3);
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth-logo img {
  height: 34px;
  width: auto;
  filter: drop-shadow(0 3px 10px rgba(201, 162, 39, .35));
}
.auth-logo .brand-name { font-size: 1.4rem; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tabs .tab {
  flex: 1; text-align: center; padding: 9px; border-radius: 999px; cursor: pointer;
  background: var(--panel2); color: var(--muted); font-weight: 600;
}
.auth-tabs .tab.active { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #1a1405; font-weight: 700; }

#aCapTurnstile { margin: 14px 0 6px; }
#aCapTurnstile .cf-turnstile { margin: 0 auto; }
#aCapTurnstile iframe { display: block; margin: 0 auto; }

.notice { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: 10px; color: var(--text); font-size: 13px; }
.err-msg { color: #ff9a8c; font-size: 13px; margin-top: 10px; min-height: 18px; }
.ok-msg { color: #7fe0ae; font-size: 13px; margin-top: 10px; }

.empty { color: var(--muted); font-size: 14px; padding: 20px; text-align: center; }

.flex { display: flex; gap: 10px; align-items: center; }
.flex.between { justify-content: space-between; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }

.champion-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  background: linear-gradient(90deg, rgba(201, 162, 39, .2), rgba(10, 92, 58, .35));
  border: 1px solid rgba(201, 162, 39, .4);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  font-family: var(--display);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.podium-line { display: inline-flex; align-items: center; gap: 8px; }
.podium-line b { font-weight: 700; }
.podium-line .flag { margin-right: 0; }
.share-page { max-width: 960px; margin: 24px auto; padding: 0 16px; }
.share-footer { text-align: center; margin: 24px 0; color: var(--muted); font-size: 12px; }

.passkey-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.passkey-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}

.soft-link {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.soft-link:hover { color: var(--gold-soft); }

.pw-check {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0 2px;
}
.pw-check-item {
  font-size: 12.5px;
  color: var(--muted);
  padding-left: 18px;
  position: relative;
}
.pw-check-item::before {
  content: "✗";
  position: absolute;
  left: 0;
  color: var(--red);
  font-weight: 700;
}
.pw-check-item.ok {
  color: #7fe0ae;
}
.pw-check-item.ok::before {
  content: "✓";
  color: #7fe0ae;
}

.rating-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 4px 0 14px;
}
.rating-tile {
  background: linear-gradient(165deg, #1e2418, #141a10);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
}
.rating-game {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 6px;
}
.rating-value {
  font-size: 34px;
  font-weight: 800;
  color: var(--gold-soft);
  line-height: 1.1;
}
.rating-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* player profile */
.player-photo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--gold);
  flex-shrink: 0;
}
.player-photo.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green), #1c5a3a);
  color: #fff;
  font-size: 34px;
  font-weight: 800;
}
.player-link { color: var(--green2); text-decoration: none; font-weight: 600; }
.player-link:hover { text-decoration: underline; color: var(--accent); }

tr.place-gold { background: rgba(201, 162, 39, .18); }
tr.place-silver { background: rgba(190, 200, 210, .16); }
tr.place-bronze { background: rgba(176, 106, 42, .16); }
tr.place-gold td, tr.place-silver td, tr.place-bronze td { border-bottom-color: rgba(0,0,0,.25); }
.tour-link { color: var(--green2); text-decoration: none; }
.tour-link:hover { text-decoration: underline; }

/* country flags */
.flag {
  display: inline-block;
  vertical-align: middle;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25), 0 1px 3px rgba(0,0,0,.5);
  margin-right: 8px;
}
.flag-20 { width: 20px; height: 14px; }
.flag-40 { width: 28px; height: 19px; }
.flag-16 { width: 16px; height: 11px; }
.match .slot .s-name .flag,
.match .slot .partner .flag,
.match .slot .s-name .flag-16,
.match .slot .partner .flag-16 { margin-right: 5px; }
.flag-cell { display: inline-flex; align-items: center; gap: 8px; }
.flag-cell .flag { margin-right: 0; }

/* country picker (custom dropdown with flags) */
.country-picker { position: relative; }
.cp-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s;
}
.cp-trigger:hover { border-color: var(--accent); }
.cp-trigger .flag { margin-right: 0; }
.cp-trigger-name { flex: 1; }
.cp-caret { color: var(--muted); font-size: 12px; }
.cp-menu {
  position: absolute;
  z-index: 30;
  left: 0; right: 0;
  top: calc(100% + 4px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.cp-search {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel2);
  padding: 8px 12px;
  font-size: 13px;
}
.cp-search:focus { box-shadow: none; border-color: var(--line); }
.cp-list { max-height: 260px; overflow-y: auto; }
.cp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
.cp-item:hover { background: var(--panel2); }
.cp-item.selected { background: rgba(201, 162, 39, .15); }
.cp-item .flag { margin-right: 0; flex-shrink: 0; }
.cp-name { flex: 1; }
.cp-none-flag {
  display: inline-block;
  width: 20px; height: 14px;
  flex-shrink: 0;
  text-align: center;
  line-height: 14px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 3px;
}

/* ===== Mobile ===== */
@media (max-width: 720px) {
  body { overflow-x: hidden; }

  main#app { padding: 12px; }

  header#topbar { padding: 8px 10px; gap: 8px; flex-wrap: nowrap; }
  .brand { gap: 6px; }
  .brand-logo { height: 26px; }
  .brand-name { font-size: 1.05rem; }
  #topbar nav { gap: 4px; flex: 1; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  #topbar nav::-webkit-scrollbar { display: none; }
  .nav-btn { padding: 8px 10px; white-space: nowrap; font-size: 13px; }
  .userbox { gap: 6px; }
  .userbox #userName { display: none; }
  .lang-switch { padding: 2px; gap: 0; }
  .lang-btn { padding: 2px 4px; }
  .lang-btn svg { width: 18px; height: 12px; }

  h1 { font-size: 21px; }
  h2 { font-size: 17px; }

  .card { padding: 12px; border-radius: 10px; }

  .tournament-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .tournament-row .badges { justify-content: flex-start; flex-wrap: wrap; }
  .tournament-row .sub { font-size: 12px; }

  .tbl { font-size: 13px; }
  .tbl th, .tbl td { padding: 7px 6px; }

  .flex.between { flex-wrap: wrap; }
  #rankTabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  #rankTabs .tab { white-space: nowrap; }

  .auth-wrap { margin: 3vh auto; }
  .auth-card { padding: 20px; }

  .modal { width: 95vw; padding: 16px; max-height: 92vh; }
  .modal .row { gap: 8px; }
  .multi-cfg { grid-template-columns: 40px minmax(42px, 1fr) minmax(0, 1.3fr) minmax(42px, 1fr) minmax(42px, 1fr); gap: 4px; }
  .score-input { font-size: 22px; }

  .player-photo { width: 72px; height: 72px; font-size: 26px; }

  .champion-banner { font-size: 15px; padding: 14px; }

  .groups-wrap { grid-template-columns: 1fr; }

  .btn { padding: 10px 16px; }
  .btn.small { padding: 6px 12px; }
  .p-list { max-height: 180px; }
  .bracket { gap: 16px; }
  .bracket .col { min-width: 180px; }
  .finals { gap: 10px; }
}

/* ===== Hamburger + drawer (mobile) ===== */
.menu-btn {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  gap: 3px;
}
.menu-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.menu-btn:hover { background: rgba(255, 255, 255, .06); }

.drawer, .drawer-backdrop { display: none; }

@media (max-width: 720px) {
  .menu-btn { display: flex; }
  #topbar nav,
  #topbar .lang-switch,
  #topbar .userbox { display: none; }
  .brand-name { font-size: 1rem; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  .drawer {
    display: flex;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 272px;
    max-width: 82vw;
    z-index: 95;
    background: linear-gradient(180deg, #1e1710, #14100c);
    border-right: 1px solid var(--line);
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 6px 0 24px rgba(0, 0, 0, .45);
  }
  body.drawer-open .drawer { transform: translateX(0); }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

  .drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 14px;
  }
  .drawer-nav .nav-btn {
    justify-content: flex-start;
    padding: 13px 14px;
    border-radius: 10px;
    font-size: 15px;
    text-align: left;
  }
  .drawer-lang { display: flex; gap: 8px; padding: 0 16px 18px; }
  .drawer-lang .lang-switch { flex-wrap: wrap; }
  .drawer-user {
    margin-top: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    border-top: 1px solid var(--line);
  }
  .drawer-logout { width: 100%; padding: 12px; }
}

/* ===== Scrollable tables ===== */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.table-scroll .tbl { min-width: max-content; }

/* ===== Draft bracket template ===== */
.draft-bracket {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  padding: 12px;
  background: rgba(10, 92, 58, .08);
  border: 1px solid rgba(10, 92, 58, .25);
  border-radius: 12px;
}
.draft-match {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.draft-slot {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(0,0,0,.2);
}
.draft-slot:last-child { border-bottom: none; }
.draft-slot.bye { color: var(--muted); font-style: italic; padding: 9px 8px; }
.seed-num {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--felt);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}
.draft-slot input.draft-search {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
}
.draft-slot input.draft-search:focus { border-color: var(--accent); outline: none; }
.draft-clear {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}
.draft-clear:hover { color: var(--red); border-color: var(--red); }
.draft-clear svg { display: block; margin: auto; }
.draft-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.roster-list {
  margin: 4px 0 0;
  padding-left: 24px;
  line-height: 1.9;
  color: var(--text);
}
.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.roster-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.roster-item .seed-num {
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 13px;
}
.roster-name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draft-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  font-size: 13px;
}
.draft-chip-x {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  line-height: 1;
}
.draft-chip-x:hover { color: var(--red); border-color: var(--red); }

/* ===== Score modal grouping ===== */
.score-row { align-items: stretch; gap: 10px; margin-bottom: 4px; }
.score-card {
  flex: 1;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.score-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-card .score-input {
  background: var(--panel);
  font-size: 26px;
  font-weight: 800;
  text-align: center;
}
.score-card .break-input {
  background: var(--panel);
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}
.score-sep {
  align-self: center;
  font-size: 26px;
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 10px;
}
.break-add { display: flex; gap: 6px; }
.break-add .break-input { flex: 1; }
.break-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.break-chips .brk-chip { padding: 3px 6px; }
.chip-x {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  margin-left: 2px;
  padding: 0;
  line-height: 1;
}
.chip-x:hover { color: var(--red); }

/* ---------- rezerwacje ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.table-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel2); }
.view-btn { padding: 7px 16px; background: transparent; color: var(--muted); border: none; cursor: pointer; font-size: 13px; font-weight: 600; transition: background .15s, color .15s; }
.view-btn + .view-btn { border-left: 1px solid var(--line); }
.view-btn.active { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #1a1405; }
.view-btn:hover:not(.active) { color: var(--text); }
.table-tile {
  width: 64px;
  min-height: 64px;
  padding: 6px 4px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.table-tile:hover { border-color: var(--accent); }
.table-tile.active { border-color: var(--accent); background: rgba(46, 125, 79, .16); }
.tt-icon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
.tt-icon svg { width: 26px; height: 26px; display: block; }
.tt-num { font-size: 12px; font-weight: 800; line-height: 1; }
.tt-cat { font-size: 8.5px; color: var(--muted); line-height: 1; white-space: nowrap; }
.cat-snooker { color: #8fd7ae; }
.cat-bilard { color: #8fb8e0; }
.cat-dart { color: #e0a08f; }
.chip {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #1a1405; border-color: transparent; }

.res-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.res-slot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  text-align: left;
  border: 1px solid var(--line);
  cursor: default;
  transition: transform .1s, box-shadow .15s;
}
.res-slot.free {
  background: rgba(46, 125, 79, .12);
  border-color: rgba(46, 125, 79, .4);
  cursor: pointer;
}
.res-slot.free:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(46, 125, 79, .18); }
.res-slot.taken { background: var(--panel2); color: var(--muted); opacity: .75; }
.res-slot .rs-time { font-weight: 800; }
.res-slot .rs-mark { font-size: 11px; opacity: .9; }

/* widok tygodniowy — kalendarz (dni = kolumny, godziny = wiersze) */
.week-grid {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.week-grid > div, .week-grid > .wg-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.week-grid > *:nth-child(8n) { border-right: none !important; }
.day-grid { display: grid; border: 1px solid var(--line); border-radius: 12px; }
.day-grid .wg-day.day-head { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 5px; padding: 4px; }
.day-grid .wg-day.day-head .tt-icon { width: 22px; height: 22px; }
.day-grid .wg-day.day-head .tt-icon svg { width: 20px; height: 20px; }
.day-grid .wg-day.day-head .day-head-text { font-size: 13px; font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.day-grid > div, .day-grid > .wg-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.wg-corner { padding: 8px; font-size: 11px; color: var(--muted); text-align: center; height: 42px; display: flex; align-items: center; justify-content: center; }
.wg-day {
  height: 42px;
  padding: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--panel2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.wg-day.today { background: rgba(46, 125, 79, .14); color: var(--green); }
.wg-day .wg-date { display: block; font-weight: 600; color: var(--muted); font-size: 11px; }
.wg-day.today .wg-date { color: var(--green); }
.wg-time {
  padding: 6px 8px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.wg-cell {
  border: none;
  padding: 2px;
  min-height: 42px;
  cursor: default;
  font-size: 11px;
  text-align: center;
  position: relative;
}
.wg-cell.closed { background: repeating-linear-gradient(45deg, rgba(0,0,0,.16), rgba(0,0,0,.16) 5px, rgba(0,0,0,.24) 5px, rgba(0,0,0,.24) 10px); }
.wg-cell.free { background: rgba(46, 125, 79, .10); cursor: pointer; }
.wg-cell.free:hover { background: rgba(46, 125, 79, .22); }
.wg-cell.free.past { background: transparent; cursor: default; }
.wg-cell.taken { background: var(--panel2); color: var(--muted); }
.wg-cell.free.overlap { background: rgba(46, 125, 79, .05); cursor: default; }
.wg-cell.free.overlap[data-book] { background: rgba(46, 125, 79, .10); cursor: pointer; }
.wg-cell.free.overlap[data-book]:hover { background: rgba(46, 125, 79, .22); }
.res-bar {
  position: absolute;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 10px;
  line-height: 1.15;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
  box-sizing: border-box;
}
.res-bar.taken { background: rgba(46, 125, 79, .55); border: 1px solid rgba(127, 224, 174, .5); color: #d9f5e4; }
.res-bar.blocked {
  background: repeating-linear-gradient(45deg, rgba(138, 47, 34, .9), rgba(138, 47, 34, .9) 5px, rgba(164, 60, 45, .9) 5px, rgba(164, 60, 45, .9) 10px);
  border: 1px solid rgba(255, 120, 110, .5);
  color: #ffd9d4;
  cursor: pointer;
}
.res-bar span { display: block; }
.res-bar.mid { font-size: 11.5px; }
.res-bar.big { font-size: 13px; }
.wg-cell.blocked {
  background: repeating-linear-gradient(45deg, #f4d7d2, #f4d7d2 5px, #f9e5e1 5px, #f9e5e1 10px);
  color: #8a2f22;
  cursor: pointer;
}
.wg-note {
  position: absolute;
  left: 2px; right: 2px; bottom: 2px;
  font-size: 10px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.now-line {
  position: absolute;
  background: #e0392e;
  border-radius: 2px;
  pointer-events: none;
  z-index: 5;
}
.now-line::before {
  content: "";
  position: absolute;
  left: 0;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e0392e;
}

/* blokada / niedostępność stołu */
.res-slot.blocked {
  background: repeating-linear-gradient(45deg, #f4d7d2, #f4d7d2 6px, #f9e5e1 6px, #f9e5e1 12px);
  border-color: rgba(180, 65, 47, .45);
  color: #8a2f22;
  cursor: pointer;
}
.res-slot.blocked .rs-mark { font-weight: 600; }
.res-closed {
  margin-top: 12px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}
.oh-input { width: 100%; }

/* Rezerwacje — wąskie ekrany: kolumny mieszczą się w widoku, mniejsze nagłówki */
@media (max-width: 720px) {
  .day-grid .wg-day.day-head { gap: 3px; padding: 2px; }
  .day-grid .wg-day.day-head .tt-icon { width: 15px; height: 15px; }
  .day-grid .wg-day.day-head .tt-icon svg { width: 13px; height: 13px; }
  .day-grid .wg-day.day-head .day-head-text { font-size: 9.5px; }
  .wg-time { font-size: 9px; padding: 4px; }
  .res-bar { font-size: 9px; padding: 1px 3px; }
  .res-bar.mid { font-size: 10px; }
  .res-bar.big { font-size: 11px; }
}

/* Poziome przesuwanie widoku rezerwacji (dużo stołów / wąski ekran) */
.grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  scrollbar-width: thin;
}
.res-grid-wrap { min-width: fit-content; }

/* przyklejona kolumna godzin (zostaje widoczna podczas przewijania) */
.day-grid .wg-time, .week-grid .wg-time,
.day-grid .wg-corner, .week-grid .wg-corner {
  position: sticky;
  left: 0;
  z-index: 2;
}
.wg-corner { background: var(--panel2); }
