/* =========================================================
   Local Tennis Rank (LTRank) — theme (step 9.5: blue first; step 9.6: dark mode through the tokens below)
   Blue   = hard court    (primary: top bar, buttons, ranks, headings) — use --atr-primary*
   Green  = court surround (the line under the top bar, good news: success, wins, ahead)
   Yellow = tennis ball   (accent only: the main call to action, badges, highlights)
   To change the brand colour, change the three --atr-primary values.
   ========================================================= */

:root {
  /* Roles (step 9.5): the hard-court blue is the brand colour; the grass green is the court surround. */
  --atr-primary: #1d5fa8;
  --atr-primary-700: #164a84;
  --atr-primary-900: #0f3560;
  --atr-green: #14532d;
  --atr-green-700: #1b6b3a;
  --atr-green-900: #0b3b1f;
  --atr-blue: #1d5fa8;
  --atr-blue-dark: #164a84;
  --atr-yellow: #d4e916;
  --atr-yellow-dark: #bcd00f;
  --atr-ink-on-yellow: #1f2a05;

  /* Surfaces and text (step 9.6): every colour that changes in dark mode is a token; dark values below. */
  --atr-bg: #f4f7fb;
  --atr-surface: #fff;
  --atr-surface-2: #f9fafb;
  --atr-surface-3: #eceeed;
  --atr-line: #e9eef5;
  --atr-text: #101828;
  --atr-text-2: #475467;
  --atr-muted: #667085;
  --atr-faint: #98a2b3;
  --atr-brand-text: var(--atr-primary);          /* the brand blue used as TEXT (ranks, links-like, outline buttons) */
  --atr-brand-text-strong: var(--atr-primary-900);
  --atr-primary-soft: #eef4fb;
  --atr-primary-line: #c9dbf1;
  --atr-success-soft: #e7f6ee;
  --atr-success-line: #dcebe1;
  --atr-success-text: #0f7a43;
  --atr-danger-soft: #fdecec;
  --atr-danger-text: #b42318;
  --atr-warning-soft: #fff6d6;
  --atr-warning-line: #f0c36d;
  --atr-warning-text: #7a5b00;
  --atr-navbar: var(--atr-primary-900);

  --bs-link-color: var(--atr-blue);
  --bs-link-color-rgb: 29, 95, 168;
  --bs-link-hover-color: var(--atr-blue-dark);
  --bs-link-hover-color-rgb: 22, 74, 132;
}

/* ---------- Dark mode (step 9.6) ----------
   <html data-bs-theme="dark"> (set by the server from the atr-theme cookie, or by theme.js for "auto").
   Bootstrap switches its own components; these are the site's tokens. A navy night, not black. */
[data-bs-theme="dark"] {
  --atr-bg: #0b1220;
  --atr-surface: #131d2e;
  --atr-surface-2: #18243a;
  --atr-surface-3: #22304a;
  --atr-line: #24324a;
  --atr-text: #e6edf7;
  --atr-text-2: #c4d0e2;
  --atr-muted: #9fb0c8;
  --atr-faint: #7d8ea8;
  --atr-brand-text: #7fb2ff;
  --atr-brand-text-strong: #a9cbff;
  --atr-primary-soft: #182844;
  --atr-primary-line: #2f4a72;
  --atr-success-soft: #12291d;
  --atr-success-line: #245a3d;
  --atr-success-text: #4ccf8a;
  --atr-danger-soft: #3a1a1d;
  --atr-danger-text: #ff8a80;
  --atr-warning-soft: #3a3015;
  --atr-warning-line: #7a6420;
  --atr-warning-text: #f3d27a;
  --atr-navbar: #08101d;

  --bs-body-bg: var(--atr-surface);
  --bs-body-bg-rgb: 19, 29, 46;
  --bs-body-color: var(--atr-text);
  --bs-body-color-rgb: 230, 237, 247;
  --bs-emphasis-color: #fff;
  --bs-secondary-color: var(--atr-muted);
  --bs-secondary-bg: var(--atr-surface-3);
  --bs-tertiary-bg: var(--atr-surface-2);
  --bs-border-color: var(--atr-line);
  --bs-link-color: #7fb2ff;
  --bs-link-color-rgb: 127, 178, 255;
  --bs-link-hover-color: #a9cbff;
  --bs-link-hover-color-rgb: 169, 203, 255;
}

/* Light-only Bootstrap helpers used in the views. */
[data-bs-theme="dark"] .text-bg-light { background-color: var(--atr-surface-3) !important; color: var(--atr-text-2) !important; }
[data-bs-theme="dark"] .bg-light { background-color: var(--atr-surface-2) !important; }
[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-color: var(--atr-text-2); --bs-btn-border-color: #46587a; --bs-btn-hover-bg: var(--atr-surface-3); --bs-btn-hover-border-color: #46587a; --bs-btn-hover-color: var(--atr-text); }

[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-border-color: var(--atr-brand-text); --bs-btn-hover-color: #fff; }

/* The theme menu in the top bar. */
.atr-theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0; }
.atr-theme-toggle svg { width: 1rem; height: 1rem; }
.atr-theme-menu .dropdown-item { display: flex; align-items: center; gap: 0.5rem; }
.atr-theme-menu .dropdown-item svg { width: 1rem; height: 1rem; }
.atr-account-menu { min-width: 14rem; max-width: 20rem; }

/* The guide (step 9.9) and the small links to it. */
.atr-guide-link { display: inline-flex; vertical-align: middle; color: var(--atr-muted); text-decoration: none; }
.atr-guide-link:hover, .atr-guide-link:focus-visible { color: var(--atr-brand-text); }
.atr-guide-link svg { width: 1em; height: 1em; }
.atr-guide { max-width: 72rem; }
.atr-guide-toc { position: sticky; top: 1rem; padding: 1rem; border-radius: 0.75rem; background: var(--atr-surface); border: 1px solid var(--atr-line); }
.atr-guide-toc li + li { margin-top: 0.35rem; }
.atr-guide-toc a { color: var(--atr-text-2); text-decoration: none; }
.atr-guide-toc a:hover { color: var(--atr-brand-text); }
.atr-guide-section { padding: 1.5rem; margin-bottom: 1rem; border-radius: 0.75rem; background: var(--atr-surface); border: 1px solid var(--atr-line); scroll-margin-top: 1rem; line-height: 1.8; }
.atr-guide-section h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.75rem; }
.atr-guide-section:target { border-color: var(--atr-brand-text); }
.atr-guide-example { padding: 0.75rem 1rem; border-radius: 0.5rem; background: var(--atr-primary-soft); border-inline-start: 3px solid var(--atr-brand-text); }
.atr-guide-table th, .atr-guide-table td { white-space: nowrap; }
.atr-guide-even { background: var(--atr-surface-2); }
@media (max-width: 991.98px) { .atr-guide-toc { position: static; } }
.atr-guide-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; position: sticky; top: -1rem; z-index: 1; margin: -1rem -1rem 1rem; padding: 0.75rem 1rem; background: var(--bs-modal-bg, var(--atr-surface)); border-bottom: 1px solid var(--atr-line); }
.atr-guide-chips a { padding: 0.2rem 0.7rem; border-radius: 999px; font-size: 0.85rem; text-decoration: none; color: var(--atr-text-2); background: var(--atr-surface-2); }
.atr-guide-chips a:hover, .atr-guide-chips a:focus-visible { color: var(--atr-brand-text); background: var(--atr-primary-soft); }
.modal .atr-guide-section { scroll-margin-top: 4rem; }
.atr-welcome-icon { display: inline-flex; align-items: center; justify-content: center; width: 3.5rem; height: 3.5rem; border-radius: 50%; background: var(--atr-primary-soft); color: var(--atr-brand-text); }
.atr-welcome-icon svg { width: 1.75rem; height: 1.75rem; }

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

/* A column: the page's content takes the free height, so the footer sits at the bottom of short pages. */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Cairo', system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  background-color: var(--atr-bg);
}

body > .container { flex: 1 0 auto; width: 100%; }   /* auto side margins would shrink it in a column */

/* ---------- Focus ring ---------- */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem var(--bs-body-bg), 0 0 0 0.25rem rgba(29, 95, 168, 0.5);
}

.form-control:focus {
  border-color: var(--atr-blue);
}

.form-check-input:checked {
  background-color: var(--atr-primary);
  border-color: var(--atr-primary);
}

/* ---------- Buttons ---------- */
.btn-primary {
  --bs-btn-bg: var(--atr-primary);
  --bs-btn-border-color: var(--atr-primary);
  --bs-btn-hover-bg: var(--atr-primary-900);
  --bs-btn-hover-border-color: var(--atr-primary-900);
  --bs-btn-active-bg: var(--atr-primary-900);
  --bs-btn-active-border-color: var(--atr-primary-900);
  --bs-btn-disabled-bg: var(--atr-primary);
  --bs-btn-disabled-border-color: var(--atr-primary);
}

.btn-outline-primary {
  --bs-btn-color: var(--atr-brand-text);
  --bs-btn-border-color: var(--atr-primary);
  --bs-btn-hover-bg: var(--atr-primary);
  --bs-btn-hover-border-color: var(--atr-primary);
  --bs-btn-active-bg: var(--atr-primary-900);
  --bs-btn-active-border-color: var(--atr-primary-900);
}

/* Tennis-ball accent button: use sparingly (main call to action). */
.btn-accent {
  --bs-btn-color: var(--atr-ink-on-yellow);
  --bs-btn-bg: var(--atr-yellow);
  --bs-btn-border-color: var(--atr-yellow);
  --bs-btn-hover-color: var(--atr-ink-on-yellow);
  --bs-btn-hover-bg: var(--atr-yellow-dark);
  --bs-btn-hover-border-color: var(--atr-yellow-dark);
  --bs-btn-active-color: var(--atr-ink-on-yellow);
  --bs-btn-active-bg: var(--atr-yellow-dark);
  --bs-btn-active-border-color: var(--atr-yellow-dark);
  font-weight: 600;
}

/* ---------- Top bar ---------- */
.atr-navbar {
  background-color: var(--atr-navbar);
  border-bottom: 3px solid var(--atr-green-700);
}

.atr-navbar .navbar-brand {
  font-weight: 700;
}

/* Racket Rank's icon (white square: the black player stays visible on the dark bar). */
.atr-brand-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: #fff;
  flex-shrink: 0;
}

/* The install bar above the header (phones). */
.atr-install-bar {
  background: var(--atr-surface, var(--bs-body-bg));
  border-bottom: 1px solid var(--bs-border-color);
  padding-top: env(safe-area-inset-top);
}
.atr-install-icon { border-radius: 0.65rem; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); flex-shrink: 0; }
.atr-install-hint { color: var(--bs-secondary-color); }

.atr-badge-accent {
  background-color: var(--atr-yellow);
  color: var(--atr-ink-on-yellow);
}

/* ---------- Home (step 9.4) ----------
   Champions board: the trophy picture under a blue-to-green veil. Each card is the player's photo with a frosted
   lower part for the details. The champion stands straight, larger and in front; 2nd and 3rd lean out.
   Picture: wwwroot/images/champions-bg.webp, the golden trophy on a green court (replace the file to change it). */
.atr-champions {
  --atr-ball: var(--atr-yellow);
  position: relative;
  overflow: hidden;
  color: #fff;
  border-radius: 1.25rem;
  padding: 1rem 3.25rem 1.1rem;
  margin-bottom: 1rem;
  background:
    linear-gradient(180deg, rgba(16, 52, 98, 0.6) 0%, rgba(14, 58, 92, 0.78) 55%, rgba(12, 60, 52, 0.9) 100%),
    url("../images/champions-bg.webp") center 40% / cover no-repeat,
    #0f3560;
}

.atr-champions-head { text-align: center; margin-bottom: 1rem; }
/* Share the slide as a picture (step 9.12): a small round button in the slide's top corner, inside the slide
   (the carousel clips anything outside it). */
.atr-champions-share {
  position: absolute; top: 0; inset-inline-end: 0; z-index: 3;
  display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 50%; color: #fff; background: rgba(8, 22, 44, 0.45);
}
.atr-champions-share:hover, .atr-champions-share:focus-visible { background: rgba(8, 22, 44, 0.7); border-color: var(--atr-ball); }
.atr-champions-share[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.atr-champions-share svg { width: 1rem; height: 1rem; }
.atr-champions-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.atr-champions-season { font-size: 0.85rem; font-weight: 600; color: var(--atr-ball); }
.atr-champions-none,
.atr-champions-first { text-align: center; margin: 0; padding: 1.5rem 0; color: rgba(255, 255, 255, 0.85); }

.atr-champions-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  padding: 0 0 1.6rem;
  list-style: none;
}

/* Position on the slide (not the rank: two players may share a place). Shown 2 - 1 - 3. */
.atr-champ {
  --tilt: 6deg;
  position: relative;
  overflow: hidden;
  flex: 0 1 12rem;
  aspect-ratio: 3 / 4;
  border-radius: 1rem;
  background: linear-gradient(160deg, var(--atr-blue), var(--atr-green-700));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  isolation: isolate;
}

[dir="ltr"] .atr-champ { --tilt: -6deg; }

.atr-champ-pos1 { order: 2; z-index: 2; flex-basis: 15rem; box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5); }
.atr-champ-pos2 { order: 1; z-index: 1; margin-inline-end: -0.35rem; transform: rotate(var(--tilt)) translateY(0.8rem); }
.atr-champ-pos3 { order: 3; z-index: 1; margin-inline-start: -0.35rem; transform: rotate(calc(-1 * var(--tilt))) translateY(0.8rem); }

.atr-champ-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
}

.atr-champ-initials {
  position: absolute;
  inset: 0 0 40% 0;
  display: grid;
  place-items: center;
  font-size: 3rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
}

.atr-champ-badge {
  position: absolute;
  top: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(10, 35, 66, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.atr-champ-crown { width: 2.3rem; height: 2.3rem; }

/* The lower part of the photo is frosted; the details sit on it. */
.atr-champ-info {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 1.6rem 0.6rem 0.6rem;
  text-align: center;
  background: linear-gradient(180deg, rgba(10, 35, 66, 0) 0%, rgba(10, 35, 66, 0.55) 35%, rgba(10, 35, 66, 0.82) 100%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 1.4rem);
  mask-image: linear-gradient(180deg, transparent 0, #000 1.4rem);
  border-radius: 0 0 1rem 1rem;   /* a blurred layer is not clipped by the card's corners in every browser */
}

.atr-champ-name {
  display: block;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.atr-champ-name:hover { color: #fff; text-decoration: underline; }
.atr-champ-pos1 .atr-champ-name { font-size: 1.1rem; }
.atr-champ-city { display: block; font-size: 0.72rem; opacity: 0.8; margin-bottom: 0.35rem; }

.atr-champ-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.15rem;
  margin: 0;
}

.atr-champ-stats div { display: flex; flex-direction: column-reverse; line-height: 1.15; }
.atr-champ-stats dd { margin: 0; font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.atr-champ-stats dt { font-size: 0.62rem; font-weight: 400; opacity: 0.75; }
.atr-champ-points dd { color: var(--atr-ball); }
.atr-champ-stats-one { grid-template-columns: 1fr !important; }
.atr-champ-stats-one dd { font-size: 1.2rem; }

.atr-champions-dots { margin-bottom: 0.35rem; }
.atr-champions-dots [data-bs-target] { width: 0.45rem; height: 0.45rem; border-radius: 50%; border: 0; background-color: rgba(255, 255, 255, 0.35); opacity: 1; }
.atr-champions-dots .active { background-color: var(--atr-ball); }

.atr-champions .atr-champions-arrow {
  top: 50%;
  bottom: auto;
  width: 2.25rem;
  height: 2.25rem;
  margin-inline: 0.5rem;
  transform: translateY(-50%);
  border-radius: 50%;
  border: 0;
  background-color: rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: rgba(255, 255, 255, 0.85);
  opacity: 0.7;
  z-index: 3;
}

.atr-champions .atr-champions-arrow:hover,
.atr-champions .atr-champions-arrow:focus-visible { opacity: 1; background-color: rgba(255, 255, 255, 0.24); }

[dir="rtl"] .atr-champions-arrow svg { transform: scaleX(-1); }

/* Phones and narrow screens: the board runs edge to edge, the cards fill the width. */
@media (max-width: 767.98px) {
  .atr-navbar-tight { margin-bottom: 0 !important; }   /* the board touches the top bar (step 9.13) */
  .atr-champions {
    margin-inline: calc(-0.5 * var(--bs-gutter-x, 1.5rem));
    border-radius: 0;
    padding: 0.85rem 0.6rem 0.8rem;
  }

  .atr-champions-row { padding: 0 0.85rem 1.1rem; }
  .atr-champions-share { inset-inline-end: 0.25rem; width: 1.9rem; height: 1.9rem; }
  .atr-champ { --tilt: 4deg; flex: 1 1 0; min-width: 0; }
  [dir="ltr"] .atr-champ { --tilt: -4deg; }
  .atr-champ-pos1 { flex: 1.3 1 0; }
  .atr-champ-pos2 { margin-inline-end: -0.15rem; transform: rotate(var(--tilt)) translateY(0.5rem) scale(0.94); }
  .atr-champ-pos3 { margin-inline-start: -0.15rem; transform: rotate(calc(-1 * var(--tilt))) translateY(0.5rem) scale(0.94); }
  .atr-champ-city,
  .atr-champ-extra { display: none !important; }
  .atr-champ-stats { grid-template-columns: repeat(2, 1fr); }
  .atr-champ-name { font-size: 0.82rem; }
  .atr-champ-pos1 .atr-champ-name { font-size: 0.92rem; }
  .atr-champ-initials { font-size: 2rem; }
  .atr-champ-badge { width: 1.7rem; height: 1.7rem; top: 0.35rem; inset-inline-start: 0.35rem; }
  .atr-champ-crown { width: 2rem; height: 2rem; }
  .atr-champions .atr-champions-arrow { width: 1.9rem; height: 1.9rem; margin-inline: 0.15rem; }
}

/* ----- The invitation, under the board ----- */
.atr-pitch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  margin-bottom: 1.5rem;
  background-color: var(--atr-surface);
  border-radius: 0.75rem;
}

.atr-pitch-text { margin: 0; max-width: 44rem; color: var(--atr-text-2); }
.atr-pitch-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ----- Your turn ----- */
.atr-turn {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.5rem;
  background-color: var(--atr-surface);
  border-inline-start: 4px solid var(--atr-primary);
  border-radius: 0.5rem;
}

.atr-turn-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: var(--atr-brand-text);
}

.atr-turn-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.atr-turn-list li + li {
  padding-inline-start: 1.25rem;
  border-inline-start: 1px solid var(--atr-line);
}

.atr-turn-empty { margin: 0; }

@media (max-width: 575.98px) {
  .atr-turn-list { flex-direction: column; }
  .atr-turn-list li + li { padding-inline-start: 0; border-inline-start: 0; }
}

/* ----- Race and results: plain blocks, rows split by hairlines ----- */
.atr-home-block {
  background-color: var(--atr-surface);
  border-radius: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
}

.atr-home-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.atr-home-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--atr-text);
}

.atr-home-aside { font-size: 0.85rem; color: var(--atr-muted); }
.atr-home-empty { color: var(--atr-muted); padding: 1.5rem 0; margin: 0; text-align: center; }
.atr-home-foot { margin-top: 0.75rem; font-size: 0.9rem; }

.atr-race {
  margin: 0;
  padding: 0;
  list-style: none;
}

.atr-race-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--atr-line);
}

.atr-race-rank {
  flex: 0 0 1.75rem;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  color: var(--atr-brand-text);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.atr-race-name { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.atr-race-name a { color: inherit; }
.atr-race-note { display: block; font-size: 0.78rem; font-weight: 400; color: var(--atr-muted); }
.atr-race-points { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--atr-brand-text); }
.atr-race-pending .atr-race-rank,
.atr-race-pending .atr-race-points { color: var(--atr-faint); }
.atr-race-me { background-color: var(--atr-primary-soft); }

.atr-feed {
  margin: 0;
  padding: 0;
  list-style: none;
}

.atr-feed-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--atr-line);
}

.atr-feed-players { display: flex; flex-direction: column; min-width: 0; }
.atr-feed-player { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--atr-text-2); }
.atr-feed-winner { font-weight: 700; color: var(--atr-text); }
.atr-feed-score { align-self: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.atr-feed-meta { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.6rem; font-size: 0.8rem; }

.atr-upset {
  padding: 0 0.5rem;
  border: 1px solid var(--atr-blue);
  border-radius: 999px;
  color: var(--atr-blue);
  font-weight: 600;
}

/* ----- The month in one line, how to start ----- */
.atr-month-line {
  max-width: 40rem;
  margin: 0 auto 2rem;
  text-align: center;
  color: var(--atr-text-2);
}

.atr-start { margin-bottom: 2rem; }

.atr-start-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: atr-step;
}

.atr-start-steps li {
  counter-increment: atr-step;
  padding-top: 0.75rem;
  border-top: 2px solid var(--atr-primary);
}

.atr-start-step {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.atr-start-step::before {
  content: counter(atr-step) ". ";
  color: var(--atr-brand-text);
}

.atr-start-steps p { margin: 0; color: var(--atr-text-2); }

.atr-card {
  border: 0;
  border-top: 4px solid var(--atr-blue);
  border-radius: 0.75rem;
  box-shadow: 0 2px 10px rgba(15, 53, 96, 0.08);
}

.atr-step {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background-color: var(--atr-yellow);
  color: var(--atr-ink-on-yellow);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Profile ---------- */
.atr-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--atr-blue);
  flex-shrink: 0;
}

.atr-avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--atr-primary);
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
}

/* The picture is a button that opens the picture menu. */
.atr-avatar-btn {
  position: relative;
  display: inline-block;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
}

.atr-avatar-btn:hover .atr-avatar,
.atr-avatar-btn[aria-expanded="true"] .atr-avatar {
  filter: brightness(0.9);
}

.atr-avatar-btn:focus-visible {
  outline: 3px solid var(--atr-blue);
  outline-offset: 3px;
}

.atr-avatar-badge {
  position: absolute;
  bottom: 2px;
  inset-inline-end: 2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--atr-yellow);
  color: var(--atr-ink-on-yellow);
  border: 2px solid var(--atr-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.atr-photo-menu .dropdown-item svg {
  margin-inline-end: 0.5rem;
  vertical-align: -3px;
}

.atr-photo-hint {
  display: block;
  max-width: 16rem;
  white-space: normal;
}

.atr-photo-large {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
}

.atr-details dt {
  font-weight: 600;
  color: var(--atr-text-2);
}

.atr-details dd {
  margin-bottom: 0.6rem;
}

.atr-bio {
  white-space: pre-line;
}

.atr-rating {
  color: var(--atr-brand-text);
}

.atr-readonly {
  background-color: var(--atr-surface-2);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

/* ---------- Account notices ---------- */
.atr-notice-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
}

.atr-notice-ok {
  background-color: var(--atr-success-soft);
  color: var(--atr-brand-text);
}

.atr-notice-fail {
  background-color: var(--atr-danger-soft);
  color: var(--atr-danger-text);
}

/* ---------- Template form-floating fix (kept) ---------- */
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ---------- Players (search + public profile) ---------- */
.atr-avatar-sm {
  width: 56px;
  height: 56px;
  border-width: 2px;
  font-size: 1.15rem;
}

.atr-player-card {
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.atr-player-card:hover,
.atr-player-card:focus-visible {
  box-shadow: 0 0.5rem 1.25rem rgba(15, 53, 96, 0.15);
  transform: translateY(-2px);
}

.atr-player-card:focus-visible {
  outline: 3px solid var(--atr-blue);
  outline-offset: 2px;
}

/* The signed-in player's own card. */
.atr-player-card-me {
  border-inline-start: 4px solid var(--atr-yellow);
}

/* A player's "@nickname" under the name (step 9.1): quiet, left to right even in Arabic. */
.atr-nickname {
  display: block;
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
  unicode-bidi: isolate;
}

.atr-badge-me {
  background-color: var(--atr-blue);
  color: #fff;
  font-weight: 600;
}

.min-w-0 {
  min-width: 0;
}

.atr-pagination {
  --bs-pagination-color: var(--atr-brand-text);
  --bs-pagination-hover-color: var(--atr-brand-text-strong);
  --bs-pagination-active-bg: var(--atr-primary);
  --bs-pagination-active-border-color: var(--atr-primary);
  --bs-pagination-focus-box-shadow: 0 0 0 0.25rem rgba(29, 95, 168, 0.25);
}

/* ---------- Player search: one box + filter panel + chips ---------- */
.atr-search .input-group-text {
  background-color: var(--atr-surface);
  color: var(--atr-muted);
}

.atr-search .form-control:focus {
  box-shadow: none;
}

.atr-search:focus-within {
  border-radius: var(--bs-border-radius);
  box-shadow: 0 0 0 0.2rem rgba(29, 95, 168, 0.2);
}

.atr-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.atr-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background-color: var(--atr-primary-soft);
  color: var(--atr-blue-dark);
  font-size: 0.875rem;
  text-decoration: none;
  border: 1px solid var(--atr-primary-line);
}

.atr-chip:hover,
.atr-chip:focus-visible {
  background-color: var(--atr-primary-soft);
  color: var(--atr-blue-dark);
}

.atr-chip-x {
  font-size: 1.1rem;
  line-height: 1;
}

/* Results fade a little while a search is running. */
.atr-results {
  transition: opacity 0.15s ease;
}

.atr-results.atr-loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Step 9.3: the list gets the focus after a page change (for screen readers); no outline around it. */
.atr-results:focus { outline: none; }

/* ---------- Back link (player page → search) ---------- */
.atr-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.9rem 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--atr-line);
  background-color: var(--atr-surface);
  color: var(--atr-brand-text);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

[dir="rtl"] .atr-back-link {
  padding: 0.35rem 0.65rem 0.35rem 0.9rem;
}

.atr-back-link:hover,
.atr-back-link:focus-visible {
  background-color: var(--atr-success-soft);
  border-color: var(--atr-primary);
  color: var(--atr-brand-text-strong);
}

.atr-back-link:focus-visible {
  outline: 3px solid var(--atr-blue);
  outline-offset: 2px;
}

/* The chevron points "back": left in English, right in Arabic. */
[dir="rtl"] .atr-back-icon {
  transform: scaleX(-1);
}

.atr-back-link:hover .atr-back-icon {
  transform: translateX(-2px);
}

[dir="rtl"] .atr-back-link:hover .atr-back-icon {
  transform: scaleX(-1) translateX(-2px);
}

/* A table's scroll box keeps everything inside it (step 9.13): without a position, absolutely placed children
   (the screen-reader names of empty headers, .visually-hidden) escape it and, in Arabic, widen the page on a phone. */
.table-responsive { position: relative; }

/* ---------- Admin area ---------- */
.atr-admin-nav {
  --bs-nav-pills-link-active-bg: var(--atr-primary);
  --bs-nav-link-color: var(--atr-brand-text);
  --bs-nav-link-hover-color: var(--atr-brand-text-strong);
  gap: 0.25rem;
}

.atr-admin-table th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--atr-text-2);
  white-space: nowrap;
}

.atr-row-inactive td {
  color: var(--atr-muted);
}

.atr-badge-active {
  background-color: var(--atr-success-soft);
  color: var(--atr-brand-text);
}

.atr-badge-inactive {
  background-color: var(--atr-surface-3);
  color: var(--atr-muted);
}

.atr-admin-tile {
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.atr-admin-tile:hover,
.atr-admin-tile:focus-visible {
  box-shadow: 0 0.5rem 1.25rem rgba(15, 53, 96, 0.15);
  transform: translateY(-2px);
}

.border-dashed {
  border-style: dashed !important;
}

/* ---------- Court owners: requests and "My courts" ---------- */
.atr-court-fields {
  border-top: 1px solid var(--atr-line);
  padding-top: 1.25rem;
}

.atr-badge-pending {
  background-color: var(--atr-warning-soft);
  color: var(--atr-warning-text);
}

.atr-badge-rejected {
  background-color: var(--atr-danger-soft);
  color: var(--atr-danger-text);
}

.atr-decision-note {
  background-color: var(--atr-surface-2);
  border-inline-start: 3px solid var(--atr-line);
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
}

/* Admin dashboard: a tile that needs attention (e.g. pending court requests). */
.atr-tile-attention {
  border-inline-start: 4px solid var(--atr-yellow);
}

/* ---------- Leaderboard ---------- */
.atr-leaderboard th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--atr-text-2);
  white-space: nowrap;
}

.atr-avatar-xs {
  width: 36px;
  height: 36px;
  border-width: 2px;
  font-size: 0.85rem;
}

.atr-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-weight: 700;
}

.atr-medal-1 { background-color: #f6d365; color: #5c4400; }
.atr-medal-2 { background-color: #d9dee2; color: #3d464d; }
.atr-medal-3 { background-color: #e9b48a; color: #5a2f10; }

/* The signed-in player's row. */
.atr-lb-me > td {
  background-color: var(--atr-primary-soft);
}

.atr-lb-gap > td {
  border-bottom: 0;
  line-height: 1;
}

.atr-lb-note {
  background-color: var(--atr-surface-2);
  border-inline-start: 3px solid var(--atr-blue);
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
}

/* ---------- Player statistics (player page and profile, step 4.4) ---------- */
.atr-up { color: var(--atr-success-text); }
.atr-down { color: var(--atr-danger-text); }

.atr-honours {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.atr-honour {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid;
}

.atr-honour-1 { background-color: #fff7db; border-color: #f3d27a; color: #7a5300; }
.atr-honour-2 { background-color: #f2f4f8; border-color: #cfd6e2; color: #3f4a5c; }
.atr-honour-3 { background-color: #fcf0e7; border-color: #ebc4a5; color: #7a3f17; }

.atr-stat {
  height: 100%;
  background-color: var(--atr-surface);
  border: 1px solid var(--atr-line);
  border-radius: 0.9rem;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.atr-stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--atr-muted);
}

.atr-stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 0.2rem;
  color: var(--atr-text);
  font-variant-numeric: tabular-nums;
}

.atr-stat-sub {
  font-size: 0.78rem;
  color: var(--atr-muted);
  margin-top: 0.2rem;
}

.atr-stat-bar {
  height: 5px;
  border-radius: 999px;
  background-color: var(--atr-line);
  margin-top: 0.45rem;
  overflow: hidden;
}

.atr-stat-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background-color: var(--atr-primary-700);
}

/* Rating chart (SVG drawn on the server; time runs left to right in both languages). */
.atr-chart {
  transition: opacity 0.15s ease;
}

[data-atr-chart].atr-loading .atr-chart {
  opacity: 0.45;
}

.atr-chart-scroll {
  overflow-x: auto;
}

.atr-chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* The chart reads left to right (time axis): keep labels inside it in an Arabic page too. */
.atr-chart-svg text {
  direction: ltr;
}

.atr-chart-grid { stroke: var(--atr-line); stroke-width: 1; }
.atr-chart-axis { fill: var(--atr-faint); font-size: 11px; font-family: inherit; }
.atr-chart-line { fill: none; stroke: var(--atr-brand-text); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.atr-chart-peak { stroke: #e0a50f; stroke-width: 1.25; stroke-dasharray: 5 4; }
.atr-chart-peak-label { fill: #b07d00; font-size: 11px; font-weight: 700; font-family: inherit; }

.atr-chart-dot {
  stroke: var(--atr-surface);
  stroke-width: 1.5;
  cursor: default;
  transition: r 0.12s ease;
}

.atr-chart-dot:hover { r: 6; }
.atr-chart-win { fill: #12a150; background-color: #12a150; }
.atr-chart-loss { fill: #d64545; background-color: #d64545; }
.atr-chart-other { fill: var(--atr-faint); }

.atr-chart-legend {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 0.35rem;
}

.atr-chart-key {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-inline-end: 0.35rem;
}

.atr-chart-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--atr-muted);
  background-color: var(--atr-surface-2);
  border: 1px dashed var(--atr-line);
  border-radius: 0.75rem;
}

/* Recent matches */
.atr-recent th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--atr-muted);
  white-space: nowrap;
  border-bottom-width: 1px;
}

.atr-result {
  display: inline-block;
  min-width: 3.2rem;
  text-align: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.atr-result-win { background-color: var(--atr-success-soft); color: var(--atr-success-text); }
.atr-result-loss { background-color: var(--atr-danger-soft); color: var(--atr-danger-text); }

.atr-score { font-variant-numeric: tabular-nums; }
.atr-set { color: var(--atr-muted); margin-inline-end: 0.5rem; }
.atr-set-won { color: var(--atr-text); font-weight: 700; }
.atr-set sup { font-size: 0.65em; margin-inline-start: 1px; }

@media (max-width: 575.98px) {
  .atr-chart-svg { min-width: 560px; }   /* readable labels: the chart scrolls sideways on phones */
  .atr-stat { padding: 0.8rem 0.85rem; }
  .atr-stat-value { font-size: 1.4rem; }
  .atr-recent { font-size: 0.85rem; }
}

/* ---------- Head-to-head (step 9.2) ---------- */
.atr-h2h-board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 1rem;
  background-color: var(--atr-surface-2);
  border-radius: 0.75rem;
}

.atr-h2h-side {
  flex: 0 1 12rem;
  min-width: 0;
  text-align: center;
  color: var(--atr-muted);
}

.atr-h2h-count {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.atr-h2h-name { font-size: 0.85rem; font-weight: 600; }
.atr-h2h-ahead { color: var(--atr-green); }
.atr-h2h-dash { font-size: 1.75rem; color: var(--atr-faint); }

.atr-h2h-facts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.atr-h2h-fact {
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--atr-line);
  border-radius: 999px;
  font-size: 0.8rem;
}

.atr-h2h-next {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

/* ---------- Challenges (step 5.2) ---------- */
.atr-player-card:focus-within {
  box-shadow: 0 0.5rem 1.25rem rgba(15, 53, 96, 0.15);
}

/* A control that stays clickable over a card's stretched link. */
.atr-over-stretched {
  position: relative;
  z-index: 2;
}

.atr-challenge-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 50%;
  color: var(--atr-brand-text);
  background-color: var(--atr-success-soft);
  border: 1px solid var(--atr-success-line);
}

.atr-challenge-btn:hover,
.atr-challenge-btn:focus-visible {
  color: #fff;
  background-color: var(--atr-primary-700);
  border-color: var(--atr-primary-700);
}

.atr-challenge-icon {
  vertical-align: -0.15em;
}

.atr-format-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.atr-format-option {
  text-align: center;
  padding: 0.75rem 0.5rem;
  border: 2px solid var(--atr-line);
  border-radius: 0.8rem;
  background-color: var(--atr-surface);
}

.btn-check:checked + .atr-format-option {
  border-color: var(--atr-primary-700);
  background-color: var(--atr-success-soft);
  color: var(--atr-brand-text-strong);
}

.btn-check:focus-visible + .atr-format-option {
  outline: 3px solid var(--atr-blue);
  outline-offset: 2px;
}

.atr-outlook-rated {
  background-color: var(--atr-success-soft);
  border: 1px solid var(--atr-success-line);
  border-radius: 0.8rem;
  padding: 0.75rem 1rem;
}

.atr-outlook-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

.atr-outlook-win { background-color: var(--atr-success-soft); color: var(--atr-success-text); }
.atr-outlook-loss { background-color: var(--atr-danger-soft); color: var(--atr-danger-text); }

.atr-challenge-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

.atr-challenge-message {
  background-color: var(--atr-surface-2);
  border-inline-start: 3px solid var(--atr-blue);
  border-radius: 0.4rem;
  padding: 0.5rem 0.75rem;
}

.atr-tabs .nav-link {
  font-weight: 600;
}

@media (max-width: 575.98px) {
  .atr-challenge-actions { width: 100%; }
  .atr-challenge-actions .btn, .atr-challenge-actions form { flex: 1 1 0; }
  .atr-challenge-actions form .btn { width: 100%; }
}

/* ---------- My matches (step 5.3) ---------- */
.atr-badge-rated {
  background-color: var(--atr-success-soft);
  color: var(--atr-success-text);
}

.atr-when {
  display: inline-block;
  margin-inline-start: 0.35rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background-color: var(--atr-primary-soft);
  color: var(--atr-blue);
  font-weight: 600;
}

.atr-venue svg {
  color: var(--atr-faint);
  vertical-align: -0.15em;
}

.atr-match-cancelled {
  opacity: 0.8;
}

/* ---------- Enter a result (step 5.4a) ---------- */
.atr-outcome .btn {
  font-weight: 600;
}

.atr-sets-head,
.atr-set-row {
  display: grid;
  grid-template-columns: minmax(6rem, 1fr) 4.5rem 4.5rem;
  gap: 0.5rem;
  align-items: center;
}

.atr-sets-head {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--atr-muted);
  text-align: center;
  margin-bottom: 0.35rem;
}

.atr-set-row {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--atr-line);
}

.atr-set-row input[type="number"] {
  text-align: center;
  font-weight: 700;
}

.atr-set-label {
  font-size: 0.9rem;
}

/* The tie-break boxes of a 7-6 set sit under the row. */
.atr-set-tb {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(6rem, 1fr) 4.5rem 4.5rem;
  gap: 0.5rem;
  align-items: center;
}

.atr-set-tb .small {
  text-align: end;
}

.atr-set-row-decider {
  margin-top: 0.5rem;
  background-color: var(--atr-warning-soft);
  border: 1px dashed var(--atr-warning-line);
  border-radius: 0.6rem;
  padding: 0.5rem;
}

.atr-result-preview {
  font-weight: 700;
  background-color: var(--atr-success-soft);
  border: 1px solid var(--atr-success-line);
  border-radius: 0.6rem;
  padding: 0.6rem 0.9rem;
}

.atr-result-preview:empty {
  display: none;
}

.atr-live-result {
  background-color: var(--atr-surface-2);
  border-radius: 0.6rem;
  padding: 0.5rem 0.75rem;
}

.atr-set-hint {
  grid-column: 1 / -1;
  text-align: end;
}

/* ---------- Match page (step 6.0) ---------- */
.atr-match-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}
.atr-match-side { flex: 1 1 0; min-width: 0; }
.atr-match-score { flex: 0 0 auto; min-width: 9rem; }
.atr-match-score .atr-score { display: flex; flex-wrap: wrap; gap: .4rem; font-size: 1.25rem; font-weight: 700; }
.atr-match-winner .atr-avatar { box-shadow: 0 0 0 3px var(--atr-accent, #c8a24a); }
.atr-timeline { border-inline-start: 2px solid var(--bs-border-color); padding-inline-start: 1rem; }
.atr-timeline-item { position: relative; display: flex; flex-wrap: wrap; gap: .25rem .75rem; padding: .3rem 0; }
.atr-timeline-item::before {
  content: "";
  position: absolute;
  inset-inline-start: calc(-1rem - 6px);
  top: .65rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bs-primary);
}
@media (max-width: 575.98px) {
  .atr-match-head { gap: .75rem; }
  .atr-match-score { min-width: 6rem; }
  .atr-match-score .atr-score { font-size: 1rem; }
}

/* ---------- Notifications (step 6.1) ---------- */
.atr-bell-menu { width: min(24rem, 92vw); }
.atr-bell-list { max-height: 26rem; overflow-y: auto; }
.atr-notif {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  padding: .65rem 1rem;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--bs-border-color-translucent);
}
.atr-notif:hover { background: var(--bs-tertiary-bg); color: inherit; }
.atr-notif-unread { background: rgba(var(--bs-primary-rgb), .06); }
.atr-notif-unread .atr-notif-text { font-weight: 600; }
.atr-notif-body { display: flex; flex-direction: column; min-width: 0; }
.atr-notif-text { font-size: .9rem; white-space: normal; }
.atr-notif-time { font-size: .75rem; color: var(--bs-secondary-color); }
.atr-notif-dot { flex: 0 0 auto; width: .6rem; height: .6rem; margin-top: .4rem; border-radius: 50%; background: var(--bs-secondary); }
.atr-notif-challenge { background: var(--bs-primary); }
.atr-notif-match { background: var(--bs-info); }
.atr-notif-result { background: var(--bs-warning); }
.atr-notif-good { background: var(--bs-success); }
.atr-notif-other { background: var(--bs-secondary); }

/* Bell on phones: outside the collapsed menu; the list opens under the navbar, full width (step 6.1). */
@media (max-width: 991.98px) {
  .atr-bell { position: static; }
  .atr-bell-menu {
    position: absolute !important;
    top: 100% !important;
    inset-inline: .5rem !important;
    width: auto;
    margin-top: .25rem;
    z-index: 1050;
  }
}
.atr-court-decision .atr-live-result:first-of-type { margin-top: .5rem; }
.atr-notif-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
}
.atr-notif-dot { margin-inline: 13px; }

/* Live toasts (step 6.2): bottom corner on the reading end side. */
/* Searchable court field (step 9.13, venue-picker.js). */
.atr-venue-picker { position: relative; }
.atr-venue-list {
  position: absolute; inset-inline: 0; top: calc(100% + 0.25rem); z-index: 1060; max-height: 18rem; overflow-y: auto;
  margin: 0; padding: 0.25rem 0; list-style: none; background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color); border-radius: 0.5rem; box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
}
.atr-venue-group { padding: 0.4rem 0.9rem 0.15rem; font-size: 0.75rem; font-weight: 700; color: var(--atr-muted); }
.atr-venue-option { padding: 0.45rem 0.9rem; cursor: pointer; }
.atr-venue-option:hover, .atr-venue-option.active { background: var(--atr-primary-soft); color: var(--atr-brand-text-strong); }
.atr-venue-option[aria-selected="true"] { font-weight: 700; }
.atr-venue-empty { color: var(--atr-muted); }
.atr-venue-none { padding: 0.45rem 0.9rem; color: var(--atr-muted); font-size: 0.9rem; }

/* At the top, in the middle (step 9.13): seen at once on a phone, never under the keyboard or the bottom bar. */
.atr-toast-stack {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: min(22rem, calc(100vw - 2rem));
}
.atr-toast {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: .75rem;
  box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .18);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-.75rem);   /* drops in from above */
  transition: opacity .25s ease, transform .25s ease;
}
.atr-toast-show { opacity: 1; transform: none; }
.atr-toast .atr-notif { border-bottom: 0; }

/* Step 9.3b: the outcome of a button on a list (live-region.js), with an optional "Show in …" link. */
.atr-toast-action {
  padding: .75rem 1rem;
  border-inline-start-width: 4px;
  font-size: .9rem;
}
.atr-toast-ok { border-inline-start-color: var(--atr-green); }
.atr-toast-error { border-inline-start-color: var(--bs-danger); }
.atr-toast-link {
  display: inline-block;
  margin-top: .25rem;
  font-weight: 600;
}

/* Confirm dialog details may hold several lines (settings changes, step 7.3). */
.atr-pre-line {
    white-space: pre-line;
}

/* Step 9.14: the phone's bottom bar (_BottomNav), like an app's tab bar. Below "lg" only (d-lg-none), where the
   top menu folds into ☰. The iPhone's home-indicator strip is added under it (viewport-fit=cover in _Layout),
   and the page gets the same room at its foot so the bar never covers the footer or the last button. */
.atr-bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 1030;                           /* over the page, under Bootstrap's dropdowns, modals and the toasts */
  display: flex;
  align-items: stretch;
  height: calc(3.75rem + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--atr-surface);
  border-top: 1px solid var(--atr-line);
  box-shadow: 0 -2px 10px rgba(16, 24, 40, 0.06);
}
.atr-bottom-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--atr-muted);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.atr-bottom-item:hover,
.atr-bottom-item:focus-visible { color: var(--atr-text); }
.atr-bottom-item:focus-visible { outline: 2px solid var(--atr-brand-text); outline-offset: -4px; border-radius: 0.5rem; }
.atr-bottom-item.active { color: var(--atr-brand-text); font-weight: 600; }
.atr-bottom-item svg { width: 1.5rem; height: 1.5rem; flex-shrink: 0; }
.atr-bottom-label {
  max-width: 100%;
  padding-inline: 0.15rem;
  font-size: 0.7rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.atr-bottom-icon { position: relative; display: inline-flex; }
.atr-bottom-badge {
  position: absolute;
  top: -0.35rem;
  inset-inline-start: 0.9rem;              /* on the icon's trailing corner */
  min-width: 1.1rem;
  padding: 0.15rem 0.3rem;
  font-size: 0.6rem;
  line-height: 1;
}
[dir="rtl"] .atr-flip-rtl { transform: scaleX(-1); }

/* Design fixes after 11.11: "More" is a button in the bar; it opens a sheet from the bottom with the top menu's pages. */
button.atr-bottom-item { background: none; border: 0; padding: 0; font: inherit; }
.atr-more-sheet { height: auto; max-height: 85vh; border-radius: 1rem 1rem 0 0; padding-bottom: env(safe-area-inset-bottom); }
.atr-more-list .list-group-item { padding-inline: .25rem; font-weight: 500; }
/* The theme and language buttons are made for the dark top bar: in the sheet they follow the page's colors. */
.atr-more-switchers .btn-outline-light { color: var(--bs-body-color); border-color: var(--bs-border-color); }
.atr-more-switchers .btn-outline-light:hover { background: var(--bs-tertiary-bg); }

@media (max-width: 991.98px) {
  body.atr-has-bottom-nav { padding-bottom: calc(3.75rem + env(safe-area-inset-bottom, 0px)); }
  /* While typing (bottom-nav.js) the keyboard is up: the bar steps aside instead of riding on top of it. */
  body.atr-typing .atr-bottom-nav { display: none; }
  body.atr-typing.atr-has-bottom-nav { padding-bottom: 0; }
}
@media print {
  .atr-bottom-nav { display: none !important; }
  body.atr-has-bottom-nav { padding-bottom: 0; }
}

/* Step 10.3: my open challenge, above the list of the others'. */
.atr-open-mine { border-inline-start: 4px solid var(--atr-brand-text); }

/* Step 10.4: open challenges on the home page, one row that scrolls sideways. On a phone each card stops in
   place (scroll-snap) and the next one peeks in, so it is clear there is more; on a computer 3 to 4 show. */
.atr-open-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(13.5rem, 78%);
  gap: 0.75rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 0.25rem;
  padding: 0.25rem 0.25rem 0.75rem;
  -webkit-overflow-scrolling: touch;
}
.atr-open-card { scroll-snap-align: start; min-width: 0; }
@media (min-width: 576px) { .atr-open-row { grid-auto-columns: minmax(13.5rem, 45%); } }
@media (min-width: 992px) { .atr-open-row { grid-auto-columns: calc((100% - 2.25rem) / 4); } }

/* Step 10.5: the players' conversation on the match page. Mine at the end of the line (right in English,
   left in Arabic), the other player's at the start; the time small under each. */
.atr-comments { display: flex; flex-direction: column; gap: 0.5rem; max-height: 22rem; overflow-y: auto; padding-inline: 0.125rem; }
.atr-comment { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; }
.atr-comment-mine { align-items: flex-end; }
.atr-comment-bubble {
  max-width: min(85%, 26rem);
  padding: 0.45rem 0.75rem;
  border-radius: 0.9rem;
  border-end-start-radius: 0.25rem;
  background: var(--atr-surface-2, var(--bs-tertiary-bg));
  border: 1px solid var(--atr-line);
  overflow-wrap: anywhere;
}
.atr-comment-mine .atr-comment-bubble {
  border-end-start-radius: 0.9rem;
  border-end-end-radius: 0.25rem;
  background: var(--atr-primary-soft, rgba(13, 110, 253, 0.1));
}
.atr-comment-author { font-size: 0.75rem; font-weight: 600; color: var(--atr-brand-text); }
.atr-comment-body { font-size: 0.9rem; }
.atr-comment-time { font-size: 0.7rem; color: var(--atr-muted); }
.atr-comment-delete { font-size: 0.75rem; }

/* Step 10.7: on a player's page the picture is a button (opens it larger) and, on your own page, the camera
   badge beside it is its own link to "My profile". */
.atr-avatar-wrap { position: relative; display: inline-block; flex-shrink: 0; }
.atr-avatar-wrap .atr-avatar-badge { text-decoration: none; }
.atr-avatar-wrap .atr-avatar-badge:focus-visible { outline: 3px solid var(--atr-blue); outline-offset: 2px; }

/* ---------------------------------------------------------------- Tournament wizard (step 11.3)
   Its own names (atr-wizard-*): .atr-step is the yellow numbered circle of the start page. */
.atr-wizard { display: flex; list-style: none; padding: 0; margin: 0; }
.atr-wizard-step { position: relative; flex: 1 1 0; min-width: 0; text-align: center; }
/* The line between two steps, behind the circles (start side, so it follows RTL). */
.atr-wizard-step + .atr-wizard-step::before {
  content: ""; position: absolute; top: 1rem; inset-inline-start: -50%; width: 100%; height: 2px;
  background: var(--bs-border-color); z-index: 0;
}
.atr-wizard-step.is-done + .atr-wizard-step::before,
.atr-wizard-step.is-done + .atr-wizard-step.is-current::before { background: var(--atr-primary); }
.atr-wizard-link { position: relative; z-index: 1; display: inline-flex; flex-direction: column; align-items: center; gap: .35rem;
  max-width: 100%; color: inherit; text-decoration: none; }
.atr-wizard-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 50%; font-weight: 700; font-size: .875rem;
  background: var(--bs-body-bg); color: var(--bs-secondary-color); border: 2px solid var(--bs-border-color);
  transition: border-color .15s, background-color .15s;
}
.atr-wizard-name { font-size: .78rem; color: var(--bs-secondary-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.atr-wizard-step.is-done .atr-wizard-dot { background: var(--atr-primary); border-color: var(--atr-primary); color: #fff; }
.atr-wizard-step.is-current .atr-wizard-dot { border-color: var(--atr-primary); color: var(--atr-brand-text);
  box-shadow: 0 0 0 4px var(--atr-primary-soft); }
.atr-wizard-step.is-current .atr-wizard-name { color: var(--bs-body-color); font-weight: 600; }
a.atr-wizard-link:hover .atr-wizard-dot { border-color: var(--atr-primary); }
a.atr-wizard-link:focus-visible { outline: 2px solid var(--atr-primary); outline-offset: 4px; border-radius: .5rem; }
@media (max-width: 575.98px) {
  .atr-wizard-name { display: none; }
  .atr-wizard-step.is-current .atr-wizard-name { display: block; }
}

/* ---------- Knockout bracket (step 11.5) ----------
   A column per round. Each round splits the column height into equal cells (flex: 1), so a match is centred between
   the two matches it comes from, and the lines meet without any measuring: a cell draws its line out to the column's
   edge and half of the vertical joint (down from the first of a pair, up from the second); the next column's match
   draws the line in. Logical properties: the same rules draw the bracket right to left in Arabic. */
.atr-bracket-scroll { overflow-x: auto; padding-bottom: .5rem; }
.atr-bracket { display: flex; align-items: stretch; width: max-content; --atr-bracket-line: var(--bs-border-color); }
.atr-bracket-round { flex: 0 0 16rem; display: flex; flex-direction: column; }
.atr-bracket-name { font-size: .8rem; font-weight: 700; color: var(--bs-secondary-color); margin: 0 0 .5rem; text-align: center; }
.atr-bracket-cells { flex: 1 1 auto; display: flex; flex-direction: column; }
.atr-bracket-cell { flex: 1 1 0; position: relative; display: flex; align-items: center; padding: .3rem 1rem; }
.atr-bracket-round:not(:last-child) .atr-bracket-cell::after {
    content: ""; position: absolute; inset-inline-end: 0; top: 50%; width: 1rem; margin-top: -1px;
    border-top: 2px solid var(--atr-bracket-line); }
.atr-bracket-round:not(:last-child) .atr-bracket-cell::before {
    content: ""; position: absolute; inset-inline-end: 0; height: 50%; border-inline-end: 2px solid var(--atr-bracket-line); }
.atr-bracket-round:not(:last-child) .atr-bracket-cell:nth-child(odd)::before { top: 50%; }
.atr-bracket-round:not(:last-child) .atr-bracket-cell:nth-child(even)::before { top: 0; }
.atr-bracket-round + .atr-bracket-round .atr-bracket-slot::before {
    content: ""; position: absolute; inset-inline-start: -1rem; top: 50%; width: 1rem; margin-top: -1px;
    border-top: 2px solid var(--atr-bracket-line); }
.atr-bracket-slot { position: relative; width: 100%; border: 1px solid var(--bs-border-color); border-radius: .5rem;
    background: var(--bs-body-bg); }
.atr-bracket-slot.is-bye { border-style: dashed; }
.atr-bracket-side { display: flex; align-items: center; gap: .45rem; padding: .3rem .5rem; font-size: .85rem; min-height: 2.35rem; }
.atr-bracket-side + .atr-bracket-side { border-top: 1px solid var(--bs-border-color); }
.atr-bracket-side.is-empty { color: var(--bs-secondary-color); font-style: italic; }
.atr-bracket-photo { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.atr-bracket-initials { display: inline-flex; align-items: center; justify-content: center; font-size: .65rem; font-weight: 700;
    font-style: normal; background: var(--bs-secondary-bg); color: var(--bs-secondary-color); }
.atr-bracket-player { flex: 1 1 auto; min-width: 0; color: inherit; text-decoration: none; }
.atr-bracket-player:hover, .atr-bracket-player:focus-visible { text-decoration: underline; }
.atr-bracket-seed { flex: 0 0 auto; min-width: 1.35rem; text-align: center; font-size: .7rem; font-weight: 700; border-radius: .25rem;
    padding: .05rem .25rem; background: var(--atr-primary-soft); color: var(--atr-brand-text); }
.atr-bracket-rating { flex: 0 0 auto; font-size: .75rem; color: var(--bs-secondary-color); font-variant-numeric: tabular-nums; }
.atr-bracket-third { max-width: 16rem; margin-top: 1.25rem; padding-inline: 1rem; }

/* Step 11.6: a round robin: standings, then a card per round (partial _RoundRobin). */
.atr-standings th { font-size: .78rem; color: var(--bs-secondary-color); font-weight: 600; white-space: nowrap; }
.atr-standings td { font-size: .88rem; }
.atr-standings .min-w-0 { min-width: 0; }
.atr-standings tr.is-podium td:first-child { color: var(--atr-primary, var(--bs-primary)); }
.atr-standings tr.is-withdrawn td { color: var(--bs-secondary-color); }
.atr-rr-rounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem 1.25rem; }
.atr-rr-round .atr-bracket-name { margin-bottom: .5rem; }
.atr-standings tr.is-qualified td:first-child { color: var(--bs-success); }
/* Step 11.9: the first three places of a completed tournament. */
.atr-places { display: grid; gap: .5rem; }
.atr-place { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.atr-place-medal { flex: 0 0 auto; width: 1.9rem; height: 1.9rem; border-radius: 50%; display: inline-flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: .9rem; border: 2px solid currentColor; }
.atr-place-1 .atr-place-medal { color: #b8860b; }
.atr-place-2 .atr-place-medal { color: #7d8a96; }
.atr-place-3 .atr-place-medal { color: #a0522d; }
.atr-place-bonus { margin-inline-start: auto; color: var(--bs-success); font-weight: 600; font-variant-numeric: tabular-nums; }
.atr-place-none { border-style: dashed; color: var(--bs-border-color); }

/* Step 11.10: tabs that scroll sideways on a phone; the organizer's path; numbers; the public players list. */
.atr-tabs-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
/* overflow-y hidden: with overflow-x auto the browser also scrolls up and down (the ring of the current dot overflows a little). */
.atr-phases { list-style: none; padding: .25rem 0; display: flex; gap: .25rem; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.atr-phase { flex: 1 1 0; min-width: 5.5rem; display: flex; flex-direction: column; align-items: center; gap: .35rem;
    text-align: center; font-size: .8rem; color: var(--bs-secondary-color); position: relative; }
.atr-phase::before { content: ""; position: absolute; top: .45rem; inset-inline: 0; height: 2px; background: var(--bs-border-color); z-index: 0; }
.atr-phase-dot { width: .95rem; height: .95rem; border-radius: 50%; border: 2px solid var(--bs-border-color); background: var(--bs-body-bg); z-index: 1; }
.atr-phase.is-done .atr-phase-dot { background: var(--bs-success); border-color: var(--bs-success); }
.atr-phase.is-current { color: var(--bs-body-color); font-weight: 700; }
.atr-phase.is-current .atr-phase-dot { border-color: var(--bs-primary); box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), .2); }
.atr-stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .75rem 1rem; }
.atr-stat-grid dt { font-weight: 400; font-size: .8rem; color: var(--bs-secondary-color); }
.atr-stat-grid dd { margin: 0; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.atr-stat-list { display: grid; gap: 1rem; }
.atr-entrants { display: grid; gap: .25rem; }
.atr-entrant { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--bs-border-color); min-width: 0; }
.atr-entrant:last-child { border-bottom: 0; }
.atr-entrant.is-withdrawn { color: var(--bs-secondary-color); }
/* Design fixes after 11.11: the tags of a tournament on the challenges' Tournaments tab, in the card's bottom corner. */
.atr-open-tournament-tags { position: absolute; inset-inline-end: .75rem; bottom: .6rem; pointer-events: none; }
/* Design fixes after 11.11: the organizer's notes on the tournament page, set apart. */
.atr-organizer-notes { border-inline-start: 3px solid var(--bs-primary); background: var(--bs-tertiary-bg); padding: .75rem 1rem; border-radius: .5rem; }
/* The public tabs share one page width (the bracket is wide); the other tabs read better narrower. */
.atr-tab-narrow { max-width: 56rem; margin-inline: auto; }
.atr-bracket-slot.is-mine { outline: 2px solid rgba(var(--bs-primary-rgb), .45); outline-offset: 1px; }
/* Step 11.7: groups + knockout: one block per group. */
.atr-group + .atr-group { border-top: 1px solid var(--bs-border-color); margin-top: 1.75rem; padding-top: 1.5rem; }
@media (max-width: 575.98px) {
    .atr-bracket-round { flex-basis: 14rem; }
}

/* Step 11.8: decided matches in the bracket (winner in bold, games per set) and the tournament badge in match lists. */
.atr-bracket-side.is-winner .atr-bracket-player { font-weight: 700; }
.atr-bracket-side.is-loser { color: var(--bs-secondary-color); }
.atr-bracket-games { flex: 0 0 auto; display: inline-flex; gap: .35rem; font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.atr-bracket-side.is-loser .atr-bracket-games { font-weight: 400; }
.atr-bracket-match { display: block; padding: .15rem .5rem; font-size: .72rem; text-align: end; border-top: 1px solid var(--bs-border-color);
    color: var(--bs-secondary-color); text-decoration: none; }
.atr-bracket-match:hover, .atr-bracket-match:focus-visible { color: var(--atr-brand-text); text-decoration: underline; }
.atr-badge-tournament { background: var(--atr-primary-soft); color: var(--atr-brand-text); font-weight: 600; }

/* The rating history page: one row per rating change. */
.atr-rh-list { list-style: none; margin: 0; padding: 0; }
.atr-rh-row { padding: 0.85rem 1rem; border-bottom: 1px solid var(--bs-border-color); }
.atr-rh-row:last-child { border-bottom: 0; }
.atr-rh-reversed { opacity: 0.6; }
.atr-rh-reversed .atr-up, .atr-rh-reversed .atr-down { text-decoration: line-through; }
.atr-rh-start { background: var(--bs-tertiary-bg); }
.atr-rh-type { font-weight: 500; background: var(--bs-secondary-bg); color: var(--bs-body-color); }
.atr-rh-type-1 { background: var(--atr-success-soft, #e5f4e4); color: var(--atr-success-text, #1d6b3a); }
.atr-rh-type-5 { background: var(--atr-warning-soft, #f9eeda); color: var(--atr-warning-text, #7a5a10); }
.atr-rh-why summary { cursor: pointer; color: var(--atr-brand-text, var(--bs-link-color)); width: fit-content; }

