/* ===== پایه ===== */
:root {
  --text: #152030;
  --muted: #64748b;
  --line: #e3e8ef;
  --bg: #eef2f8;
  --surface: #ffffff;
  --accent: #2f5fe0;
  --accent-dark: #1f44ad;
  --accent-soft: #eaf0ff;
  --accent-2: #f97316;
  --ok: #15803d;
  --ok-soft: #e9f8ef;
  --err: #d33a2c;
  --err-soft: #fdeeec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(21, 32, 48, .06), 0 8px 24px rgba(21, 32, 48, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.85 Vazirmatn, Vazir, "Segoe UI", Tahoma, sans-serif;
  -webkit-text-size-adjust: 100%;
}

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

h1 { font-size: 1.35rem; margin: 0 0 10px; letter-spacing: -.2px; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
h3 { font-size: 1rem; margin: 20px 0 8px; }
.muted { color: var(--muted); font-size: .9rem; font-weight: normal; }

/* ===== نوار بالا ===== */
.appbar {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: #fff;
  padding: 18px 20px;
}

/* ===== قاب‌ها ===== */
.wrap {
  max-width: 580px;
  margin: 22px auto;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.wrap.narrow { max-width: 400px; }
.wrap.wide { max-width: 1040px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 16px 0;
}

/* ===== فرم‌ها ===== */
label, fieldset { display: block; margin: 0 0 16px; }
fieldset { border: 0; padding: 0; }
legend { padding: 0; margin-bottom: 4px; }

input[type=text], input[type=password], input[type=search], input[type=number], input[type=tel], select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 13px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input[type=file] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  font: inherit;
  font-size: .9rem;
  background: var(--accent-soft);
  border: 1px dashed #b9cbf5;
  border-radius: 10px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 95, 224, .15);
}
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.row { display: grid; gap: 0 14px; }
.date { display: grid; grid-template-columns: 1fr 1.6fr 1.2fr; gap: 8px; }
.date select { margin-top: 0; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: 18px; height: 18px; margin: 0; }
form.inline { display: inline; }

button {
  width: 100%;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
button:hover { background: var(--accent-dark); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .6; cursor: wait; }
button.light, .btn.light { background: #fff; color: var(--accent); border: 1px solid #c7d6f7; }
button.light:hover { background: var(--accent-soft); }
button.danger { background: var(--err); }
button.danger:hover { background: #b12d21; }
button.small { width: auto; padding: 7px 14px; font-size: .85rem; font-weight: 500; margin: 0; }

.btn {
  display: inline-block;
  margin-top: 10px;
  padding: 11px 22px;
  color: #fff;
  background: var(--accent);
  border-radius: 10px;
  font-weight: 700;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }

/* ===== پیام‌ها ===== */
.box { padding: 12px 16px; border-radius: 12px; margin: 16px 0; font-size: .95rem; }
.box.err { background: var(--err-soft); color: var(--err); border: 1px solid #f7cdc8; }
.box.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #bce7cd; }
.box ul { margin: 0; padding-inline-start: 18px; }
.box p { margin: 4px 0; }
.big { font-size: 1.6rem; letter-spacing: 1px; }

/* ===== فهرست مسابقات ===== */
.comps { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; }
.comp {
  padding: 16px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--accent);
  border-radius: 12px;
}
.comp h2 { margin: 0 0 4px; font-size: 1.05rem; }
.comp p { margin: 4px 0; }
.comp.closed { border-inline-start-color: #cbd5e1; background: #fafbfd; }
.desc { white-space: pre-wrap; font-size: .95rem; }
.tag {
  display: inline-block; margin-top: 10px; padding: 5px 14px;
  background: #eef1f6; color: var(--muted); border-radius: 999px; font-size: .85rem;
}
.back { margin: 0 0 10px; font-size: .9rem; }

/* ===== جدول‌ها و پنل مدیر ===== */
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.top .links { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .9rem; }
.top h2 { margin: 24px 0 8px; }

.search { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.search input, .search select { margin: 0; flex: 1 1 160px; width: auto; }
.search button { width: auto; padding: 11px 22px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.actions #selCount { margin-inline-end: auto; }
.actions button { width: auto; padding: 8px 15px; margin: 0; font-weight: 500; }

.table { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; white-space: nowrap; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; }
thead th { background: #f7f9fc; color: var(--muted); font-weight: 500; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
.expired { color: var(--err); font-weight: 700; }
.table input[type=checkbox] { width: 18px; height: 18px; vertical-align: middle; }
td.ltr { direction: ltr; text-align: left; font-size: .85rem; }
.tiny { width: 70px; margin-top: 0; padding: 6px 8px; }

td.dl { white-space: nowrap; }
td.dl a {
  display: inline-block; margin: 2px; padding: 4px 12px;
  font-size: .85rem; color: var(--accent); background: var(--accent-soft);
  border-radius: 999px;
}
td.dl a:hover { background: #dbe6ff; text-decoration: none; }

.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pager a, .pager strong { padding: 4px 12px; border: 1px solid var(--line); border-radius: 8px; }
.pager strong { background: var(--accent); color: #fff; border-color: var(--accent); }

.info { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 16px 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; }

.docs { display: grid; gap: 16px; }
.docs figure { margin: 0; }
.docs img { display: block; width: 100%; border: 1px solid var(--line); border-radius: 10px; }
.docs figcaption { font-size: .9rem; color: var(--muted); margin-top: 6px; }

/* ===== جدول مسابقات ===== */
.stages { display: grid; gap: 10px 16px; grid-template-columns: 1fr; margin: 12px 0; }
details.card > summary { cursor: pointer; font-weight: 700; }
.bo { font-size: .75rem; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 10px; }

.rounds { display: flex; gap: 14px; overflow-x: auto; padding: 4px 0 10px; }
.round { display: flex; flex-direction: column; justify-content: space-around; min-width: 215px; }
.rname { font-size: .85rem; color: var(--muted); margin-bottom: 8px; text-align: center; }
.match {
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; margin: 7px 0; font-size: .9rem; overflow: hidden;
  box-shadow: 0 1px 2px rgba(21, 32, 48, .05);
}
.match.bye { opacity: .65; }
.match .mno { font-size: .72rem; color: var(--muted); padding: 5px 10px 2px; }
.match .pl { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-top: 1px solid var(--line); }
.match .pl.win { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.match .pl b { font-variant-numeric: tabular-nums; }
.gmatches { display: grid; gap: 10px; grid-template-columns: 1fr; margin-bottom: 20px; }

details.res { border-top: 1px dashed var(--line); padding: 6px 10px 10px; }
details.res summary { font-size: .8rem; color: var(--accent); cursor: pointer; }
.rrow { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.rrow span { flex: 1; font-size: .85rem; }
.rrow input[type=number] { width: 72px; margin: 0; padding: 7px; }

/* ===== معرفی‌نامه ===== */
.letter-page { background: #e9ebef; }
.toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line);
}
.toolbar button { width: auto; padding: 8px 16px; }
.toolbar select { width: auto; max-width: 40%; padding: 8px; margin: 0; }
.toolbar .hint { flex-basis: 100%; margin: 0; }

.paper {
  width: 210mm; max-width: 100%; min-height: 297mm;
  margin: 16px auto; padding: 16mm 18mm;
  background: #fff; color: #000;
  font-size: 11.5pt; line-height: 2;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.ed { white-space: pre-wrap; min-height: 1.5em; border-radius: 3px; }
.ed:hover, [contenteditable]:hover { background: #fffbe6; }
.ed:focus, td[contenteditable]:focus { outline: 1px dashed var(--accent); background: #fffbe6; }
.ed.inline { display: inline-block; min-width: 6em; vertical-align: top; }

.lhead { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; margin-bottom: 24px; }
.lhead .org { font-weight: bold; text-align: center; justify-self: start; }
.lhead .center { text-align: center; font-weight: bold; }
.lhead .meta { justify-self: end; font-size: 10.5pt; }
.lhead .meta span { margin-left: 4px; }
.recipient { font-weight: bold; margin-bottom: 4px; }
.subject { font-weight: bold; margin-bottom: 12px; }
.body { text-align: justify; margin-bottom: 12px; }

.players { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 10.5pt; white-space: normal; }
.players th, .players td { border: 1px solid #000; padding: 4px 6px; text-align: center; background: none; }
.players th { background: #f0f0f0; color: #000; font-weight: bold; }
.players tr.off td { color: #999; text-decoration: line-through; }
.players tr.off td.no-print { text-decoration: none; }
.sign { margin-top: 24px; margin-inline-start: auto; width: 50%; text-align: center; page-break-inside: avoid; }
.sign .signer { font-weight: bold; }
.lfoot { margin-top: auto; padding-top: 8px; border-top: 1px solid #000; font-size: 9.5pt; text-align: center; }

/* ===== واکنش‌گرا ===== */
@media (min-width: 600px) {
  .row { grid-template-columns: 1fr 1fr; }
  .docs { grid-template-columns: repeat(3, 1fr); }
  .stages { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 700px) {
  .gmatches { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .wrap { margin: 0; border-radius: 0; box-shadow: none; padding: 18px 16px; min-height: 100vh; }
  .actions button { flex: 1 1 100%; }
  .paper { margin: 0; padding: 16px; min-height: 0; font-size: 10pt; box-shadow: none; }
  .players { font-size: 9pt; }
  .sign { width: 100%; }
}

/* ===== چاپ ===== */
@page { size: A4; margin: 14mm 16mm; }
@media print {
  .no-print, .appbar, details.res { display: none !important; }
  body, .letter-page { background: #fff; }
  .wrap { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .paper { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  .lfoot { margin-top: 24px; }
  .ed:hover, [contenteditable]:hover, .ed:focus { background: none; outline: none; }
  .players tr.off { display: none; }
  .players .expired { color: #000; font-weight: normal; }
  .players thead { display: table-header-group; }
  .players tr { page-break-inside: avoid; }
  .rounds { overflow: visible; }
  .match { box-shadow: none; }
}

/* ===== منو ===== */
.appbar { padding: 0 16px; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 12px rgba(21, 32, 48, .12); }
.appbar .inner { max-width: 1040px; height: 60px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.appbar .brand {
  display: flex; align-items: center; gap: 10px; margin-inline-end: 18px;
  color: #fff; font-weight: 700; font-size: 1rem; white-space: nowrap;
}
.appbar .brand:hover { text-decoration: none; }
.appbar .brand .logo {
  display: grid; place-items: center; width: 36px; height: 36px;
  background: rgba(255, 255, 255, .18); border-radius: 10px; font-size: 1.15rem;
}
.ic { width: 20px; height: 20px; flex: none; }
[dir="rtl"] .ic.flip { transform: scaleX(-1); }
.topnav a[href="logout.php"] { margin-inline-start: auto; }
.topnav { flex: 1; }

/* منوی بالا (کامپیوتر) */
.topnav { display: flex; gap: 4px; }
.topnav a, .pubnav {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 10px;
  color: rgba(255, 255, 255, .88); font-size: .92rem; transition: background .15s, color .15s;
}
.topnav a:hover, .pubnav:hover { background: rgba(255, 255, 255, .14); color: #fff; text-decoration: none; }
.topnav a.active, .pubnav.active { background: #fff; color: var(--accent-dark); font-weight: 700; }

/* نوار پایین (موبایل) */
.tabbar { display: none; }
.letter-page .toolbar { top: 60px; }

@media (max-width: 760px) {
  .appbar .inner { height: 56px; }
  .letter-page .toolbar { top: 56px; }
  .topnav { display: none; }
  .pubnav span { display: none; }
  .pubnav { padding: 8px 10px; }

  .tabbar {
    position: fixed; z-index: 30; inset-inline: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 18px rgba(21, 32, 48, .08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 62px; color: var(--muted); font-size: .72rem; font-weight: 500;
  }
  .tabbar a:hover { text-decoration: none; color: var(--accent); }
  .tabbar .ic { width: 23px; height: 23px; }
  .tabbar a.active { color: var(--accent); font-weight: 700; }
  .tabbar a.active::before {
    content: ""; position: absolute; top: 0; width: 34px; height: 3px;
    background: var(--accent); border-radius: 0 0 4px 4px;
  }
  .tabbar a.active .ic {
    background: var(--accent-soft); border-radius: 999px; padding: 3px 14px;
    width: 52px; height: 30px; box-sizing: border-box;
  }
  .tabbar a[href="logout.php"] { color: #a1a9b6; }

  /* جا برای نوار پایین */
  body.has-tabbar { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  body.has-tabbar .wrap { min-height: calc(100vh - 56px - 70px); }
}

/* ===== صفحهٔ ثبت نتیجه ===== */
.vs {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  margin: 18px 0 14px;
}
.who {
  background: var(--accent-soft); border: 1px solid #cfdcfb; border-radius: 12px;
  padding: 12px 10px; text-align: center; font-weight: 700; line-height: 1.5;
}
.who b { display: block; font-size: 1.8rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.who.win { background: var(--ok-soft); border-color: #a9e2c0; }
.who.win b { color: var(--ok); }
.vsx { color: var(--muted); font-size: .8rem; }

.games { display: grid; gap: 8px; }
.grow {
  display: grid; grid-template-columns: auto 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.grow.off { opacity: .45; }
.grow.w1 { border-inline-start: 4px solid var(--ok); }
.grow.w2 { border-inline-end: 4px solid var(--ok); }
.grow .gno { font-size: .85rem; color: var(--muted); min-width: 56px; }
.grow .dash { color: var(--muted); }
.grow input { margin: 0; text-align: center; padding: 10px 6px; font-size: 1.05rem; }
.sum { margin: 14px 0; font-size: .92rem; color: var(--muted); }
.sum.ok { color: var(--ok); font-weight: 700; }

/* ===== سیدبندی ===== */
.info-box { background: var(--accent-soft); color: var(--text); border: 1px solid #cfdcfb; }
.seedlist { display: grid; gap: 10px; margin: 16px 0; }
.seedrow {
  display: grid; grid-template-columns: 1fr 90px 1fr; align-items: end; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.seedrow .pname { font-weight: 600; }
.mini { margin: 0; font-size: .8rem; color: var(--muted); }
.mini input { margin-top: 4px; padding: 8px 10px; }

@media (max-width: 600px) {
  .seedrow { grid-template-columns: 1fr 86px; }
  .seedrow .pname { grid-column: 1 / -1; }
  .seedrow .mini.wide { grid-column: 2 / 3; }
  .vs { grid-template-columns: 1fr; }
  .vsx { text-align: center; }
}

/* دکمهٔ ثبت نتیجه روی کارت بازی */
.match .enter {
  display: block; text-align: center; padding: 8px;
  font-size: .82rem; color: var(--accent); background: var(--accent-soft);
  border-top: 1px solid var(--line);
}
.match .enter:hover { background: #dbe6ff; text-decoration: none; }
.match .gl { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 5px 8px 7px; }
.match .gl span { background: #f2f5fa; border-radius: 6px; padding: 0 6px; font-variant-numeric: tabular-nums; }

/* ===== جدول حذفی راست‌به‌چپ با خطوط اتصال ===== */
.bracket {
  --g: 36px; --ln: #c3cddc;
  display: flex; gap: var(--g); overflow-x: auto;
  padding: 6px 4px 14px; margin-bottom: 8px;
}
.bracket .col { display: flex; flex-direction: column; flex: 0 0 214px; }
.bracket .rname {
  text-align: center; white-space: nowrap; margin-bottom: 10px;
  font-size: .85rem; font-weight: 700; color: var(--accent-dark);
  background: var(--accent-soft); border-radius: 999px; padding: 4px 10px;
}
.bracket .rname .bo { background: #fff; }
.bracket .colbody { flex: 1; display: flex; flex-direction: column; }
.bracket .slot { flex: 1; position: relative; display: flex; flex-direction: column; justify-content: center; padding: 7px 0; }
.bracket .slot .match { margin: 0; position: relative; z-index: 1; }

/* خط خروجی به دور بعد (سمت چپ در راست‌به‌چپ) */
.bracket .col.to-pair .slot::after {
  content: ""; position: absolute; top: 50%;
  inset-inline-end: calc(var(--g) / -2); width: calc(var(--g) / 2);
  border-top: 2px solid var(--ln);
}
.bracket .col.to-straight .slot::after {
  content: ""; position: absolute; top: 50%;
  inset-inline-end: calc(var(--g) * -1); width: var(--g);
  border-top: 2px solid var(--ln);
}
/* خط عمودی که دو بازی را به هم وصل می‌کند */
.bracket .col.to-pair .slot::before {
  content: ""; position: absolute;
  inset-inline-end: calc(var(--g) / -2 - 1px);
  border-inline-end: 2px solid var(--ln);
}
.bracket .col.to-pair .slot:nth-child(odd)::before { top: 50%; bottom: 0; }
.bracket .col.to-pair .slot:nth-child(even)::before { top: 0; bottom: 50%; }
/* خط ورودی از دور قبل */
.bracket .cin {
  position: absolute; top: 50%;
  inset-inline-start: calc(var(--g) / -2); width: calc(var(--g) / 2);
  border-top: 2px solid var(--ln);
}

@media (max-width: 600px) {
  .bracket { --g: 26px; }
  .bracket .col { flex-basis: 188px; }
}
@media print {
  .bracket { overflow: visible; }
}

/* ===== سیدبندی با جابه‌جایی ===== */
.sortlist { list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 8px; }
.sitem {
  display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  transition: box-shadow .15s, background .3s;
}
.sitem.dragging { box-shadow: 0 10px 24px rgba(21, 32, 48, .18); border-color: var(--accent); background: var(--accent-soft); z-index: 2; position: relative; }
.sitem.moved { animation: seedflash .6s; }
@keyframes seedflash { from { background: #fff3d6; } to { background: #fff; } }

.hdl {
  width: 34px; height: 40px; margin: 0; padding: 0;
  background: none; color: #9aa6b7; font-size: 1.3rem; line-height: 1;
  cursor: grab; touch-action: none; border-radius: 8px;
}
.hdl:hover { background: #f2f5fa; color: var(--accent); }
.dragging .hdl { cursor: grabbing; }
.hdl-ex { color: var(--accent); font-weight: 700; }

.snum {
  display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 6px;
  background: var(--accent); color: #fff; border-radius: 10px; font-weight: 700; font-size: .95rem;
}
.sitem:nth-child(n+17) .snum { background: #94a3b8; }
.sbody { min-width: 0; }
.sbody .pname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbody input { margin-top: 4px; padding: 6px 10px; font-size: .85rem; }

.arrows { display: flex; flex-direction: column; gap: 4px; }
.arrows button {
  width: 38px; height: 30px; margin: 0; padding: 0; font-size: .75rem;
  background: #f2f5fa; color: var(--accent); border-radius: 8px;
}
.arrows button:hover { background: #dbe6ff; }
.arrows button:disabled { opacity: .3; cursor: default; background: #f2f5fa; }

.stickybar {
  position: sticky; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: 2fr 1fr; gap: 8px;
  padding: 10px 0; background: linear-gradient(to top, #fff 75%, rgba(255, 255, 255, 0));
}
.stickybar button { margin: 0; }
body.has-tabbar .stickybar { bottom: 0; }
@media (max-width: 760px) {
  body.has-tabbar .stickybar { bottom: calc(62px + env(safe-area-inset-bottom)); }
}

/* ===== جدول بازی‌های گروه (۴ ستون) ===== */
.ggrid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 10px 0 26px; padding: 10px; background: #f6f8fc;
  border: 1px solid var(--line); border-radius: 12px;
}
.gm {
  width: 100%; margin: 0; padding: 10px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: .88rem; font-weight: 500; line-height: 1.5; text-align: center;
  cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .05s;
}
div.gm { cursor: default; }
button.gm:hover { background: #fff; border-color: var(--accent); box-shadow: 0 2px 10px rgba(47, 95, 224, .15); }
.gm .gn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm .gn.w { color: var(--ok); font-weight: 700; }
.gm .gs { font-size: .75rem; color: var(--muted); padding: 1px 10px; background: #f2f5fa; border-radius: 999px; }
.gm.done { border-color: #bce7cd; }
.gm.done .gs { background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: .85rem; }

@media (max-width: 760px) { .ggrid { grid-template-columns: repeat(2, 1fr); padding: 8px; } }

/* ===== دیالوگ ثبت نتیجه ===== */
.rdlg {
  width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 24px);
  padding: 0; border: 0; border-radius: 18px; box-shadow: 0 20px 60px rgba(21, 32, 48, .3);
}
.rdlg::backdrop { background: rgba(15, 23, 42, .45); }
.rdlg form { padding: 18px; }
.rd-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 14px; }
.rd-p {
  background: var(--accent-soft); border: 1px solid #cfdcfb; border-radius: 12px;
  padding: 10px 8px; text-align: center; font-weight: 700; line-height: 1.5; font-size: .95rem;
}
.rd-p b { display: block; font-size: 1.7rem; color: var(--accent); }
.rd-p.win { background: var(--ok-soft); border-color: #a9e2c0; }
.rd-p.win b { color: var(--ok); }
.rd-vs { color: var(--muted); font-size: .8rem; }
.rd-rows { display: grid; gap: 8px; }
.rd-row {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center;
  padding: 4px; border-radius: 12px; border: 1px solid transparent;
}
.rd-row select { margin: 0; text-align: center; text-align-last: center; font-size: 1.1rem; padding: 10px 6px; }
.rd-row .rd-g { font-size: .8rem; color: var(--muted); min-width: 52px; text-align: center; }
.rd-row.w1 select:first-child, .rd-row.w2 select:last-child { border-color: var(--ok); background: var(--ok-soft); font-weight: 700; }
.rd-row.off { opacity: .35; }
.rd-sum { margin: 12px 0; font-size: .9rem; color: var(--muted); text-align: center; }
.rd-sum.ok { color: var(--ok); font-weight: 700; }
.rd-wo { margin: 8px 0 14px; font-size: .9rem; }
.rd-wo summary { cursor: pointer; color: var(--muted); }
.rd-wo label { margin: 6px 0; }
.rd-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.rd-actions button { margin: 0; }
.rd-actions #rd-clear { grid-column: 1 / -1; }
.danger-text { color: var(--err) !important; border-color: #f2c6c0 !important; }

/* دکمهٔ ثبت نتیجه روی کارت بازی حذفی */
.match button.enter {
  width: 100%; margin: 0; padding: 9px; border: 0; border-top: 1px solid var(--line); border-radius: 0;
  background: var(--accent-soft); color: var(--accent); font-size: .82rem; font-weight: 500;
}
.match button.enter:hover { background: #dbe6ff; }
.match:target { box-shadow: 0 0 0 3px rgba(47, 95, 224, .35); }

/* ===== صفحهٔ ثبت‌نام ===== */
.reg { max-width: 640px; margin: 0 auto; padding: 18px 14px 40px; }
.hero {
  position: relative; overflow: hidden;
  padding: 22px 20px; margin-bottom: 14px; border-radius: 18px; color: #fff;
  background: radial-gradient(circle at 15% 20%, rgba(255,255,255,.18) 0 60px, transparent 61px),
              linear-gradient(135deg, var(--accent-dark), var(--accent) 60%, #4f7cf0);
  box-shadow: var(--shadow);
}
.hero::after {
  content: "🏓"; position: absolute; inset-inline-end: 14px; bottom: -10px;
  font-size: 4.5rem; opacity: .16; transform: rotate(-15deg);
}
.hero-tag { display: inline-block; font-size: .78rem; background: rgba(255,255,255,.2); padding: 2px 12px; border-radius: 999px; }
.hero h1 { margin: 8px 0 6px; font-size: 1.3rem; line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: rgba(255,255,255,.18); border-radius: 999px; padding: 3px 12px; font-size: .85rem; }
.hero-desc { margin: 10px 0 0; font-size: .9rem; opacity: .92; white-space: pre-wrap; }

.reg .card { padding: 18px; margin: 0 0 14px; box-shadow: 0 1px 2px rgba(21,32,48,.04); }
.step-h { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 14px; }
.sn {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent); font-size: .9rem;
}
.reg input.nc { letter-spacing: 3px; font-size: 1.1rem; text-align: center; }
.reg .invalid { border-color: var(--err) !important; background: var(--err-soft); }

.vh { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pickers { display: grid; gap: 12px; grid-template-columns: 1fr; }
.picker {
  position: relative; display: block; margin: 0; cursor: pointer;
  border: 2px dashed #b9cbf5; border-radius: 14px; background: #f7f9ff;
  min-height: 112px; overflow: hidden; transition: border-color .15s, background .15s;
}
.picker:hover { border-color: var(--accent); background: var(--accent-soft); }
.picker:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,95,224,.15); }
.pk-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 112px; padding: 14px; color: var(--accent); text-align: center;
}
.pk-empty svg { width: 34px; height: 34px; }
.pk-empty b { font-size: .98rem; }
.pk-empty small { color: var(--muted); }
.pk-full { display: none; }
.pk-busy { display: none; }
.picker.busy .pk-empty, .picker.busy .pk-full { display: none; }
.picker.busy .pk-busy { display: grid; place-items: center; min-height: 112px; color: var(--muted); font-size: .9rem; }
.picker.has { border-style: solid; border-color: #a9e2c0; background: #fff; }
.picker.has .pk-empty { display: none; }
.picker.has .pk-full { display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto; align-items: center; gap: 2px 12px; padding: 10px; }
.pk-full img { grid-row: 1 / 3; width: 96px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.pk-ok { color: var(--ok); font-weight: 700; font-size: .92rem; align-self: end; }
.pk-change { color: var(--accent); font-size: .85rem; align-self: start; }
.picker.bad { border-color: var(--err); background: var(--err-soft); }
.picker.bad .pk-empty b { color: var(--err); }

.submit { padding: 15px; font-size: 1.05rem; border-radius: 14px; box-shadow: 0 6px 18px rgba(47,95,224,.3); }

.done-card { text-align: center; }
.done-ic {
  width: 64px; height: 64px; margin: 4px auto 8px; display: grid; place-items: center;
  border-radius: 50%; background: var(--ok-soft); color: var(--ok); font-size: 2rem; font-weight: 700;
}
.done-card h2 { margin: 0 0 6px; }
.regno {
  display: inline-flex; flex-direction: column; margin: 12px 0 4px; padding: 10px 28px;
  border-radius: 14px; background: var(--accent-soft); color: var(--muted); font-size: .85rem;
}
.regno b { font-size: 2rem; color: var(--accent-dark); letter-spacing: 2px; }

@media (min-width: 600px) {
  .pickers { grid-template-columns: repeat(3, 1fr); }
  .picker.has .pk-full { grid-template-columns: 1fr; grid-template-rows: auto; text-align: center; }
  .pk-full img { grid-row: auto; width: 100%; height: 90px; }
}

/* ===== تعداد و اسامی ثبت‌نام‌کنندگان در کارت مسابقه ===== */
.regcount {
  display: inline-flex; align-items: center; gap: 8px; margin: 10px 0 4px;
  padding: 4px 14px 4px 6px; background: var(--accent-soft); border-radius: 999px;
  font-size: .88rem; color: var(--accent-dark);
}
.rc-num {
  display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px;
  background: var(--accent); color: #fff; border-radius: 999px; font-weight: 700;
}
.namelist { margin: 6px 0 2px; }
.namelist summary { cursor: pointer; color: var(--accent); font-size: .9rem; width: fit-content; }
.namelist ol {
  margin: 8px 0 0; padding: 10px 12px; padding-inline-start: 34px;
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px;
  columns: 2; column-gap: 24px; font-size: .9rem; max-height: 320px; overflow-y: auto;
}
.namelist li { break-inside: avoid; padding: 2px 0; }
@media (max-width: 600px) { .namelist ol { columns: 1; } }
.namelist ol { list-style-type: persian; }

/* ===== مهلت ثبت‌نام ===== */
.countdown {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  margin: 10px 0 2px; padding: 10px 14px; border-radius: 12px;
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
}
.countdown .cd-label { font-size: .85rem; }
.countdown .cd-left { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.countdown .cd-date { flex-basis: 100%; font-size: .8rem; }
.countdown.soon { background: #fef2f2; border-color: #fecaca; color: var(--err); }
.countdown.soon .cd-left { animation: cdpulse 1.6s ease-in-out infinite; }
@keyframes cdpulse { 50% { opacity: .55; } }
.dl-time { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.dl-time select { width: auto; margin: 0; }

/* ویژگی hidden همیشه پنهان کند */
[hidden] { display: none !important; }

/* ===== مدارک قابل تنظیم و پرداخت ===== */
.reqbox { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fafbfd; }
.reqbox legend { padding: 0 6px; font-weight: 700; }
.reqbox label.check { margin: 0 0 8px; }
.paycfg { margin: 4px 0 6px; padding: 12px; border: 1px dashed #b9cbf5; border-radius: 10px; background: #fff; }

.paybox {
  border-radius: 14px; padding: 14px; text-align: center;
  background: linear-gradient(135deg, #f0f5ff, #fff7ed); border: 1px solid #dbe4f7;
}
.pay-amount { display: flex; align-items: baseline; justify-content: center; gap: 8px; color: var(--muted); }
.pay-amount b { font-size: 1.9rem; color: var(--accent-dark); letter-spacing: .5px; }
.pay-card { margin-top: 10px; padding: 10px; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.pc-label { display: block; font-size: .82rem; color: var(--muted); }
.pc-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 4px 0; }
.pc-num { font-size: 1.25rem; letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.pc-copy { width: auto; margin: 0; padding: 5px 14px; font-size: .82rem; font-weight: 500; background: var(--accent-soft); color: var(--accent); border-radius: 999px; }
.pc-copy:hover { background: #dbe6ff; }
.pc-holder { display: block; font-size: .88rem; }
.pay-note { margin: 8px 0 0; font-size: .85rem; color: var(--muted); white-space: pre-wrap; }

.feetag { display: inline-block; margin: 8px 0 0; margin-inline-end: 8px; padding: 4px 12px; border-radius: 999px; background: #fff7ed; color: #9a3412; font-size: .88rem; }

/* چیدمان کادر انتخاب عکس بر اساس تعداد مدارک */
@media (min-width: 600px) {
  .pickers.n1 { grid-template-columns: 1fr; }
  .pickers.n2 { grid-template-columns: repeat(2, 1fr); }
  .pickers.n1 .picker.has .pk-full { grid-template-columns: 120px 1fr; text-align: start; }
  .pickers.n1 .pk-full img { grid-row: 1 / 3; width: 120px; height: 90px; }
}

@media (max-width: 599px) { .reg .row > label + label { margin-top: 16px; } }

/* ============================================================
   صفحهٔ مسابقات: هر مسابقه یک کارت مستقل
   ============================================================ */
.cl { max-width: 1040px; margin: 0 auto; padding: 20px 16px 48px; }
.cl-h { font-size: 1.35rem; margin: 4px 4px 16px; }
.cl-empty { background: #fff; border-radius: 16px; padding: 28px; text-align: center; color: var(--muted); box-shadow: var(--shadow); }
.cgrid { display: grid; gap: 18px; grid-template-columns: 1fr; align-items: start; }

.cc {
  background: #fff; border-radius: 18px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(21,32,48,.06), 0 10px 28px rgba(21,32,48,.08);
  display: flex; flex-direction: column;
}
.cc-head {
  position: relative; overflow: hidden; color: #fff;
  padding: 16px 18px 18px;
  background: linear-gradient(135deg, #1f44ad, #2f5fe0 55%, #4f7cf0);
}
/* توپ تزئینی گوشهٔ سربرگ کارت */
.cc-head::before {
  content: ""; position: absolute; width: 120px; height: 120px; border-radius: 50%;
  inset-inline-end: -36px; top: -46px; background: rgba(255,255,255,.12);
}
.cc-head::after {
  content: ""; position: absolute; width: 26px; height: 26px; border-radius: 50%;
  inset-inline-end: 22px; bottom: 14px; background: #fff; opacity: .9;
  box-shadow: inset -4px -4px 0 rgba(240,138,28,.55);
}
.cc-status {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; padding: 3px 12px; border-radius: 999px; background: rgba(255,255,255,.2);
}
.cc-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }
.cc h2 { position: relative; margin: 10px 0 6px; font-size: 1.12rem; line-height: 1.7; padding-inline-end: 40px; }
.cc-meta { position: relative; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .86rem; opacity: .92; }

.cc.is-closed .cc-head { background: linear-gradient(135deg, #475569, #64748b); }
.cc.is-closed .cc-status::before { background: #fca5a5; }

.cc-body { padding: 14px 18px 4px; flex: 1; }
.cc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.st { background: #f5f7fb; border-radius: 12px; padding: 10px 12px; text-align: center; }
.st b { display: block; font-size: 1.35rem; color: var(--accent-dark); line-height: 1.4; }
.st span { font-size: .78rem; color: var(--muted); }

.cc .countdown {
  display: flex; align-items: center; gap: 10px; margin: 10px 0 0;
  padding: 10px 12px; border-radius: 12px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
}
.cc .countdown .cd-ic { font-size: 1.3rem; }
.cc .countdown b { display: block; font-size: 1.02rem; }
.cc .countdown small { font-size: .76rem; opacity: .85; }
.cc .countdown.soon { background: #fef2f2; border-color: #fecaca; color: var(--err); }

.cc-desc {
  margin: 12px 0 0; font-size: .9rem; color: #475569; white-space: pre-wrap;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cc .namelist { margin: 10px 0 4px; }

.cc-actions {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid #eef1f6; margin-top: 10px;
}
.cc-actions .btn { margin: 0; flex: 1 1 auto; text-align: center; padding: 10px 18px; }

@media (min-width: 760px) {
  .cgrid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   صفحهٔ ثبت‌نام: خلاصه و کم‌حجم
   ============================================================ */
.reg { max-width: 560px; }
.reg .hero { padding: 16px 18px; margin-bottom: 12px; }
.reg .hero::after { font-size: 3.4rem; }
.reg .hero h1 { margin: 0 0 6px; font-size: 1.15rem; }
.hero-more { margin-top: 8px; font-size: .88rem; }
.hero-more summary { cursor: pointer; opacity: .9; width: fit-content; }
.hero-more p { margin: 6px 0 0; white-space: pre-wrap; opacity: .95; }

.rf { padding: 4px 16px 16px; }
.rf-sec { padding: 14px 0; border-bottom: 1px solid #eef1f6; }
.rf-sec:last-of-type { border-bottom: 0; }
.rf label { margin: 0; font-size: .9rem; }
.rf fieldset { margin: 0 0 10px; }
.rf fieldset:last-child { margin-bottom: 0; }
.rf legend { font-size: .9rem; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rf input[type=text], .rf input[type=tel], .rf select { padding: 10px 12px; margin-top: 4px; }
.reg input.nc { letter-spacing: 1.5px; font-size: 1rem; }

.rf .paybox { padding: 12px; text-align: center; }
.rf .pay-amount { display: block; color: var(--text); font-size: .92rem; }
.rf .pay-amount b { font-size: 1.35rem; color: var(--accent-dark); }
.rf .pc-row { margin: 6px 0 2px; }
.rf .pc-num { font-size: 1.12rem; }
.rf .pc-holder { font-size: .82rem; color: var(--muted); }

.reg .pickers { display: grid; grid-template-columns: 1fr; gap: 8px; }
.reg .picker { min-height: 0; border-width: 1.5px; border-radius: 12px; }
.reg .pk-empty { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 54px; padding: 8px 14px; text-align: start; }
.reg .pk-empty svg { width: 24px; height: 24px; flex: none; }
.reg .pk-empty b { font-size: .92rem; }
.reg .picker.has .pk-full { grid-template-columns: 54px 1fr auto; grid-template-rows: auto; gap: 10px; padding: 6px 10px; text-align: start; }
.reg .pk-full img { grid-row: auto; width: 54px; height: 40px; border-radius: 8px; }
.reg .pk-ok { align-self: center; font-size: .88rem; }
.reg .pk-change { align-self: center; font-size: .8rem; }
.reg .picker.busy .pk-busy { min-height: 54px; }
.reg .submit { margin-top: 6px; padding: 13px; }
.reg .box.err small { display: block; margin-top: 4px; }

.reg .done-card p { margin: 4px 0; }

@media (min-width: 600px) {
  .reg .pickers { grid-template-columns: repeat(2, 1fr); }
  .reg .picker.has .pk-full { grid-template-columns: 54px 1fr auto; text-align: start; }
  .reg .pk-full img { width: 54px; height: 40px; }
}
@media (max-width: 380px) { .g2 { grid-template-columns: 1fr; } }
.rf label { line-height: 1.7; }
.rf .g2 label input { margin-top: 3px; }
