/*
  ----------------------------------------
  UI Components
  ----------------------------------------

  Breakpoints (defined as --bp-* in theme.css; CSS @media can't use vars):
    --bp-sm: 36rem   (576px)
    --bp-md: 48rem   (768px)
    --bp-lg: 56rem   (896px)
    --bp-xl: 64rem   (1024px)
*/

@layer styles {
  /* Disabled links */
  a[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
  }

  /* Buttons
  ---------------------------------- */
  .ui-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;       /* Figma spec: 8px 14px */
    height: 2.25rem;                 /* Figma spec: 36px */
    border-radius: var(--rounded-md); /* Figma spec: 6px */
    border: var(--border) solid transparent;
    background: var(--brand-1);      /* Default = navy */
    color: var(--white);
    font-size: 0.9375rem;            /* 15px floor */
    font-weight: 500;
    line-height: 1.25rem;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;

    &:hover {
      background: var(--brand-1-900);  /* #021438 */
    }

    &:active {
      transform: translateY(0.5px);
    }

    &:disabled,
    &.disabled {
      background: var(--brand-1-200);  /* #8FA0C3 */
      cursor: not-allowed;
      pointer-events: none;
    }

    /* ── Semantic solid variants ───────────────── */

    &.ui-brand-1 {
      background: var(--brand-1);
      color: var(--white);
      &:hover    { background: var(--brand-1-900); }
      &:disabled, &.disabled { background: var(--brand-1-200); color: var(--white); }
    }

    &.ui-success,
    &.ui-brand-2 {
      background: var(--success);
      color: var(--white);
      &:hover    { background: var(--success-dark); }
      &:disabled, &.disabled { background: var(--success-mid); color: var(--white); }
    }

    &.ui-info,
    &.ui-brand-3 {
      background: var(--info);
      color: var(--white);
      &:hover    { background: var(--info-dark); }
      &:disabled, &.disabled { background: var(--info-mid); color: var(--white); }
    }

    &.ui-warning,
    &.ui-brand-4 {
      background: var(--warning);
      color: var(--white);
      &:hover    { background: var(--warning-dark); }
      &:disabled, &.disabled { background: var(--warning-mid); color: var(--white); }
    }

    &.ui-error {
      background: var(--error);
      color: var(--white);
      &:hover    { background: var(--error-dark); }
      &:disabled, &.disabled { background: var(--error-mid); color: var(--white); }
    }

    /* Gray — light bg with dark text */
    &.ui-gray,
    &.ui-neutral-lighter,
    &.ui-neutral-light {
      background: var(--secondary-bg);
      color: var(--secondary-text);
      border-color: transparent;
      &:hover    { background: var(--lighter); }
      &:disabled, &.disabled { background: var(--gray-50); color: var(--text-meta); }
    }

    /* Legacy neutral (midtone gray, white text) — kept for compat */
    &.ui-neutral {
      background: var(--midtone);
      color: var(--white);
      &:hover    { background: var(--dark); }
      &:disabled, &.disabled { opacity: 0.5; }
    }

    /* Dark — near-black bg with white text, used for homepage CTAs */
    &.ui-dark {
      background: var(--darker);
      color: var(--white);
      &:hover    { background: var(--dark); }
      &:disabled, &.disabled { opacity: 0.5; }
    }

    /* ── Outline type — .ui-outline + optional semantic ── */

    &.ui-outline {
      background: transparent;
      border-color: var(--brand-1);
      color: var(--brand-1);

      &:hover    { background: var(--brand-1-50); }
      &:disabled, &.disabled {
        background: transparent;
        border-color: var(--brand-1-200);
        color: var(--brand-1-200);
      }

      &.ui-success, &.ui-brand-2 {
        border-color: var(--success);
        color: var(--success);
        &:hover    { background: var(--success-light); }
        &:disabled, &.disabled { border-color: var(--success-mid); color: var(--success-mid); }
      }

      &.ui-info, &.ui-brand-3 {
        border-color: var(--info);
        color: var(--info);
        &:hover    { background: var(--info-light); }
        &:disabled, &.disabled { border-color: var(--info-mid); color: var(--info-mid); }
      }

      &.ui-warning, &.ui-brand-4 {
        border-color: var(--warning);
        color: var(--warning);
        &:hover    { background: var(--warning-light); }
        &:disabled, &.disabled { border-color: var(--warning-mid); color: var(--warning-mid); }
      }

      &.ui-error {
        border-color: var(--error);
        color: var(--error);
        &:hover    { background: var(--error-light); }
        &:disabled, &.disabled { border-color: var(--error-mid); color: var(--error-mid); }
      }

      &.ui-gray, &.ui-neutral-lighter, &.ui-neutral-light, &.ui-neutral {
        border-color: var(--text-meta);
        color: var(--secondary-text);
        &:hover    { background: var(--lighter); }
        &:disabled, &.disabled { border-color: var(--secondary-bg); color: var(--text-meta); }
      }
    }

    /* ── Icon-only square button ───────────────── */

    &.ui-icon {
      padding: 0.5rem;
      width: 2.25rem;
    }

    /* ── Link-style button ─────────────────────── */

    &.ui-link {
      background: none;
      border-color: transparent;
      border-radius: 0;
      padding: 0;
      height: auto;
      font-weight: inherit;
      font-size: inherit;
      color: var(--link);
      text-decoration: underline;
      line-height: inherit;

      &:hover    { background: none; opacity: 0.75; }
      &:active   { transform: none; }
      &:disabled, &.disabled { opacity: 0.4; background: none; }
    }
  }

  /* Buttons mini-round */
  .ui-button-mini-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: var(--rounded-full);
    background: var(--lighter);
    color: var(--brand-1);
    box-shadow: var(--shadow-sm);
    transition: all 250ms ease;

    &:hover {
      background: var(--brand-1);
      color: var(--lighter);
    }
  }

  /* Badge
  ---------------------------------- */
  .ui-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6875rem;      /* Base: 4px 11px — Figma spec */
    border-radius: var(--rounded-full); /* Pill shape */
    background: var(--lighter);
    color: var(--darker);
    font-size: 0.9375rem;            /* 15px floor */
    font-weight: 500;
    line-height: 1.25rem;            /* 20px */
    white-space: nowrap;

    /* ── Sizes ──────────────────────────────────── */

    &.ui-sm {
      padding: 0.25rem 0.4375rem;    /* 4px 7px */
      font-size: 0.9375rem;          /* 15px floor */
      line-height: 1rem;             /* 16px */
    }

    &.ui-lg {
      padding: 0.4375rem 0.875rem;   /* 7px 14px */
    }

    /* ── Ghost variants (light bg + colored text) ── */

    &.ui-success {
      background: var(--success-light);
      color: var(--success);
    }

    &.ui-error {
      background: var(--error-light);
      color: var(--error);
    }

    &.ui-warning {
      background: var(--warning-light);
      color: var(--warning);
    }

    &.ui-info {
      background: var(--info-light);
      color: var(--info);
    }

    &.ui-secondary {
      background: var(--secondary-bg);
      color: var(--secondary-text);
    }

    /* ── Solid variants (.ui-solid + state) ─────── */

    &.ui-solid {
      background: var(--darker);
      color: var(--white);

      &.ui-success {
        background: var(--success);
        color: var(--success-light);
      }

      &.ui-error {
        background: var(--error);
        color: var(--error-light);
      }

      &.ui-warning {
        background: var(--warning);
        color: var(--warning-light);
      }

      &.ui-info {
        background: var(--info);
        color: var(--info-light);
      }

      &.ui-secondary {
        background: var(--text-meta);  /* #909090 — Figma secondary solid bg */
        color: var(--gray-50);         /* #F9FAFB ≈ Figma #F9F9FA */
      }
    }
  }

  /* Filter pills — radio-button pill group used in list filters.
     Each label holds a hidden radio. CSS :has() drives the active state so
     no server re-render or extra JS is needed.
     Set --pill-active-bg (and optionally --pill-active-color) on each label
     to control the activated colour:
       style="--pill-active-bg: var(--error)"
  ---------------------------------- */
  .ui-filter-pill {
    background: var(--pill-bg, var(--secondary-bg));
    color: var(--secondary-text);
    border-color: transparent;
    &:hover { background: var(--lighter); }

    .ui-badge {
      background: var(--lighter);
      color: var(--darker);
    }

    &:has(input[type="radio"]:checked) {
      background: var(--pill-active-bg, var(--midtone));
      color: var(--pill-active-color, var(--white));
      border-color: transparent;
      &:hover { background: var(--pill-active-bg, var(--midtone)); filter: brightness(0.9); }

      /* ── Badge active states — solid variant triggered by class on .ui-badge ── */
      .ui-badge.ui-brand-1 { background: var(--brand-1); color: var(--white); }
      .ui-badge.ui-error   { background: var(--error);   color: var(--white); }
      .ui-badge.ui-warning { background: var(--warning); color: var(--warning-light); }
      .ui-badge.ui-success { background: var(--success); color: var(--success-light); }
    }
  }

  /* Alert / Callout
  ---------------------------------- */
  .ui-alert {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--rounded-md);
    border: var(--border) solid transparent;
    font-size: 0.9375rem;  /* 15px floor */

    /* Default / neutral */
    background: var(--lighter);
    color: var(--darker);
    border-color: var(--light);

    &.ui-success {
      background: var(--success-light);
      color: var(--success-dark);
      border-color: var(--success-mid);
    }

    &.ui-warning {
      background: var(--warning-light);
      color: var(--warning-dark);
      border-color: var(--warning-mid);
    }

    &.ui-info {
      background: var(--info-light);
      color: var(--info-dark);
      border-color: var(--info-mid);
    }

    &.ui-error {
      background: var(--error-light);
      color: var(--error-dark);
      border-color: var(--error-mid);
    }
  }

  /* Homepage Hero
  ---------------------------------- */
  .ui-home-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl) var(--space-lg);
    overflow: hidden;
  }

  /* Full-bleed background video */
  .ui-home-hero__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 0;
  }

  /* Dark overlay so text is readable */
  .ui-home-hero__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
    pointer-events: none;
  }

  .ui-home-hero__content {
    position: relative;
    z-index: 10;
    width: min(100%, 42rem);
    margin: 0 auto;
    text-align: center;
  }

  .ui-home-hero__search {
    width: min(100%, 26rem);
    margin: 0 auto;
  }

  /* Feature image cards row at the bottom of the hero */
  .ui-home-hero__cards {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    width: 100%;
    justify-content: center;
    position: relative;
    z-index: 10;
  }

  .ui-home-feature-card {
    flex: 1 1 16rem;
    max-width: 22rem;
    min-height: 10rem;
    border-radius: var(--rounded-lg);
    background: var(--lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .ui-home-feature-card__image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 10rem;
    color: var(--midtone);
  }

  /* General section wrapper */
  .ui-home-section {
    width: 100%;
  }

  /* Upcoming Tournaments
  ---------------------------------- */

  /* Custom dropdown styled inline with the heading */
  .ui-home-state-select {
    position: relative;
    display: inline-block;
  }

  .ui-home-state-trigger {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid var(--brand-1);
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: var(--brand-1);
    cursor: pointer;
    padding: 0 0.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
  }

  .ui-home-state-menu {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    z-index: 50;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 0.25rem 0;
    min-width: 10rem;
    max-height: 16rem;
    overflow-y: auto;
    list-style: none;
    margin: 0;

    &[hidden] { display: none; }
  }

  .ui-home-state-menu li button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem 0.875rem;
    font-size: var(--text-sm);
    color: var(--darker);
    white-space: nowrap;
  }

  .ui-home-state-menu li button:hover {
    background: var(--lighter);
    color: var(--brand-1);
  }

  .ui-home-tournament-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg);
  }

  .ui-home-tournament-col {
    flex: 1 1 14rem;
    min-width: 0;
  }

  .ui-home-tournament-link {
    font-weight: 700;
    color: var(--brand-1);
    text-decoration: none;
    line-height: 1.35;

    &:hover { text-decoration: underline; }
  }

  .ui-home-tournament-meta {
    margin: 0;
  }

  /* Latest News
  ---------------------------------- */
  .ui-home-news-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg);
    align-items: flex-start;
  }

  .ui-home-news-main {
    flex: 2 1 28rem;
    min-width: 0;
  }

  .ui-home-news-sidebar {
    flex: 1 1 16rem;
    min-width: 0;
  }

  .ui-home-featured-post {
    background: var(--dark);
    color: var(--white);
    border-radius: var(--rounded-lg);
    padding: var(--space-xl) var(--space-lg);
    min-height: 12rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;

    h3 { margin: 0; color: var(--white); }
  }

  .ui-home-article-row {
    display: flex;
    gap: var(--space-md);
    align-items: stretch;
    padding-bottom: var(--space-md);
  }

  .ui-home-article-thumb {
    flex: 0 0 40%;
    align-self: stretch;
    border-radius: var(--rounded-md);
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .ui-home-article-body {
    flex: 1;
    min-width: 0;

    h4 { margin: 0; }
  }

  .ui-home-fb-card {
    background: var(--white);
    border-radius: 1.5rem;
    padding: var(--space-lg);
  }

  .ui-home-fb-post {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-start;
    padding: var(--space-xs) 0;
  }

  .ui-home-fb-thumb {
    flex-shrink: 0;
    width: 3.5rem;
    height: 3rem;
    border-radius: var(--rounded-md);
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .ui-home-ad-placeholder {
    background: var(--light);
    border-radius: var(--rounded-md);
    height: 12rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Sponsors
  ---------------------------------- */
  .ui-home-sponsors-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
  }

  .ui-home-sponsor-logo {
    height: 6rem;
    border-radius: var(--rounded-md);
    background: var(--white);
    border: 1px solid var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .ui-tournament-page__layout {
    display: grid;
    align-items: start;
  }

  .ui-tournament-page__layout {
    grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr);
  }

  .ui-tournament-page__layout--single {
    grid-template-columns: 1fr;
  }

  .ui-tournament-page__layout > * {
    min-width: 0;
  }

  .ui-division-page__year-filter {
    max-width: 16rem;
  }

  .ui-division-page__layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr);
    align-items: start;
  }

  .ui-division-page__layout > * {
    min-width: 0;
  }

  .ui-division-page__next-row > * {
    min-width: 0;
  }

  .ui-tournament-page__details,
  .ui-division-page__info {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
  }

  /* Newsletter
  ---------------------------------- */
  .ui-home-newsletter {
    margin: 0 auto;
    text-align: center;
    padding: var(--space-2xl) var(--space-xl);
    background: var(--lighter);
    border-radius: 1.5rem;
  }

  /* Responsive overrides — single-column on narrow screens */
  @media (max-width: 36rem) { /* --bp-sm */
    .ui-home-feature-card { max-width: 100%; }

    .ui-home-article-row {
      flex-direction: column;

      .ui-home-article-thumb { width: 100%; min-height: 8rem; }
    }

    .ui-home-newsletter { padding: var(--space-lg) var(--space-md); }

    .ui-home-sponsors-grid { grid-template-columns: repeat(2, 1fr); }

    .ui-tournament-page__details {
      grid-template-columns: 1fr;
    }

    .ui-division-page__year-filter {
      max-width: 100%;
    }

    .ui-division-page__meta {
      gap: var(--space-2xs);
    }

    .ui-division-page__next-row {
      flex-direction: column;
      align-items: stretch;
    }

    .ui-division-page__next-action .ui-button,
    .ui-division-page__next-action form {
      width: 100%;
    }

    .ui-division-page__next-action .ui-button {
      justify-content: center;
    }

    .ui-division-page__info {
      grid-template-columns: 1fr;
    }
  }

  @media (max-width: 56rem) { /* --bp-lg */
    .ui-tournament-page__layout {
      grid-template-columns: 1fr;
    }

    .ui-division-page__layout {
      grid-template-columns: 1fr;
    }

    .ui-division-page__sidebar {
      order: -1;
    }
  }

  .ui-home-tournaments {
    scroll-margin-top: calc(4rem + var(--space-md));
  }

  /* Marketing Header
  ---------------------------------- */
  .ui-marketing-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--brand-1-900);
    border-bottom: 1px solid var(--brand-1-900);
  }

  .ui-marketing-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 4rem;
    gap: var(--space-lg);
  }

  .ui-marketing-nav__logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--white);
    font-weight: 700;
    font-size: var(--text-lg);
    flex-shrink: 0;

    img { height: 1.75rem; width: auto; }
  }

  /* Nav links pushed right, away from logo */
  .ui-marketing-nav__links {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;

    li {
      display: flex;
      align-items: center;

      /* Pipe divider between items */
      & + li::before {
        content: "";
        display: block;
        width: 1px;
        height: 1.1rem;
        background: var(--light);
        margin: 0 var(--space-sm);
      }
    }

    a {
      font-weight: 600;
      font-size: var(--text-sm);
      color: var(--white);
      text-decoration: none;
      white-space: nowrap;

      &:hover { color: var(--brand-1); }
    }
  }

  .ui-marketing-nav__actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
  }

  .ui-marketing-nav__cta {
    font-size: var(--text-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    border-radius: var(--rounded-lg);
    white-space: nowrap;
  }

  .ui-marketing-nav__hamburger {
    display: none !important;
  }

  /* Responsive: collapse nav at 56rem */
  @media (max-width: 56rem) { /* --bp-lg */
    .ui-marketing-nav__links {
      display: none;
    }

    .ui-marketing-nav__cta {
      display: none;
    }

    .ui-marketing-nav__hamburger {
      display: block !important;
    }
  }

  /* Marketing Footer
  ---------------------------------- */
  .ui-marketing-footer {
    position: relative;
    background: var(--secondary-text);
    border-top: 1px solid var(--light);
    padding: var(--space-xl) var(--space-lg);
    margin-top: var(--space-xl);
  }

  .ui-marketing-footer__grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-xl);
    align-items: start;
  }

  .ui-marketing-footer__brand {
    grid-column: span 2;
    .main-logo--footer {
      max-height: 2.5rem;
      height: auto;
      width: auto;
    }
  }

  .ui-marketing-footer__heading {
    margin: 0 0 var(--space-sm);
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--white);
  }

  .ui-marketing-footer__links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);

    a { text-decoration: none; &:hover { color: var(--white); } }
  }

  .ui-marketing-footer__tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  /* Pill-style tag badge */
  .ui-marketing-footer__tag {
    display: inline-block;
    font-size: 0.9375rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--midtone);
    text-decoration: none;
    background: var(--white);
    border: 1px solid var(--light);
    border-radius: var(--rounded-full);
    padding: 0.2rem 0.6rem;

    &:hover {
      color: var(--brand-1);
      border-color: var(--brand-1);
    }
  }

  /* Back-to-top circular button */
  .ui-back-to-top {
    position: absolute;
    top: calc(-1.5rem);
    right: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: var(--rounded-full);
    background: var(--dark);
    color: var(--white);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: background 0.15s ease;

    &:hover { background: var(--darker); color: var(--white); }
  }

  @media (max-width: 48rem) { /* --bp-md */
    .ui-marketing-footer__grid { grid-template-columns: repeat(2, 1fr); }
  }

  @media (max-width: 36rem) { /* --bp-sm */
    .ui-marketing-footer__grid { grid-template-columns: 1fr; }
  }

  /* Tournament Panels
  ---------------------------------- */

  .ui-tournament-panel {
    display: flex;
    flex: 1 1 32rem;
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
    max-width: 34rem;
    height: 100%;
    max-height: 50rem;
    padding: var(--space-lg);
    border: 1px solid rgb(255 255 255 / 0.08);
    border-radius: 1rem;
    background:
      radial-gradient(circle at top, rgb(255 255 255 / 0.05), transparent 45%),
      linear-gradient(145deg, rgb(39 39 42 / 0.94), rgb(24 24 27 / 0.98));
    box-shadow:
      0 24px 40px -24px rgb(0 0 0 / 0.65),
      inset 0 1px 0 rgb(255 255 255 / 0.06);

    .ui-tournament-header {
      display: flex;
      flex-direction: column;
      gap: var(--space-sm);

      .ui-tournament-title {
        margin: 0;
        color: var(--white);
        font-size: var(--text-lg);
        font-weight: 800;
        line-height: 1.1;
        text-transform: uppercase;
        letter-spacing: 0.02em;
      }

      .ui-tournament-divider {
        height: 2px;
        width: 100%;
        background: linear-gradient(90deg, var(--error), rgb(239 68 68 / 0.15));
      }
    }

    .ui-tournament-list {
      display: flex;
      flex: 1;
      flex-direction: column;
      gap: 0;
      margin: 0;
      padding: 0 var(--space-2xs) 0 0;
      list-style: none;
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: rgb(255 255 255 / 0.18) transparent;

      .ui-standing-row {
        display: grid;
        grid-template-columns: 4rem minmax(0, 1fr) 5rem;
        gap: var(--space-sm);
        align-items: center;
        padding: var(--space-sm) 0;
        border-bottom: 1px solid rgb(255 255 255 / 0.08);

        span:last-child {
          text-align: right;
        }
      }

      .ui-standing-row--head {
        color: rgb(212 212 216);
        font-size: var(--text-sm);
        font-weight: 800;
        letter-spacing: 0.04em;
        text-transform: uppercase;
      }

      .ui-tournament-item {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        padding: var(--space-sm) 0;
        border-bottom: 1px solid rgb(255 255 255 / 0.08);
        transition:
          transform 120ms ease,
          background-color 120ms ease;

        .ui-tournament-date {
          display: inline-flex;
          flex-shrink: 0;
          align-items: center;
          justify-content: center;
          min-width: 4.75rem;
          padding: var(--space-2xs) var(--space-xs);
          border-radius: 0.45rem;
          background: linear-gradient(
            135deg,
            rgb(127 29 29 / 0.92),
            rgb(69 10 10 / 0.92)
          );
          color: rgb(254 202 202);
          font-size: var(--text-sm);
          font-weight: 800;
          letter-spacing: 0.06em;
        }

        .ui-tournament-name {
          color: rgb(244 244 245);
          font-size: var(--text-base);
          font-weight: 500;
          line-height: 1.35;
        }
      }

      .ui-tournament-item:hover {
        transform: translateX(0.15rem);
      }

      .ui-tournament-item:last-child {
        border-bottom: 0;
      }
    }

    .ui-tournament-list::-webkit-scrollbar {
      width: 0.35rem;
    }

    .ui-tournament-list::-webkit-scrollbar-thumb {
      border-radius: var(--rounded-full);
      background: rgb(255 255 255 / 0.18);
    }

    .ui-tournament-list::-webkit-scrollbar-track {
      background: transparent;
    }
  }

  @media (max-width: 40rem) {
    .ui-tournament-panel {
      min-height: auto;
      padding: var(--space-md);
    }

    .ui-tournament-item {
      align-items: flex-start;
      flex-direction: column;
    }
  }

  /* Hamburger Button
  ---------------------------------- */
  .ui-hamburger-button {
    --button-width: 1.875rem;        /* 30px */
    --button-height: 1.5rem;         /* 24px */
    --line-thickness: 0.1875rem;     /* 3px */
    --line-color: var(--darker);
    --line-radius: var(--rounded-sm); /* 2px */
    --number-of-spins: 5;
    --duration: 0.15s;
    --focus-color: rgba(0, 0, 0, 0.2);

    position: relative;
    display: block;
    width: var(--button-width);
    height: var(--button-height);
    cursor: pointer;
    outline: none;

    .line-1,
    .line-2,
    .line-3 {
      position: absolute;
      display: block;
      width: 100%;
      height: var(--line-thickness);
      background-color: var(--line-color);
      border-radius: var(--line-radius);
      transition: all var(--duration) ease-in-out;
    }

    .line-2 {
      top: calc(50% - var(--line-thickness) / 2);
    }

    .line-3 {
      bottom: 0;
    }

    /* Hamburger animate */
    [data-ui-hamburger-open-value="true"] & {
      .line-1 {
        transform: translateY(
            calc(var(--button-height) / 2 - var(--line-thickness) / 2)
          )
          rotate(calc(-1 * 45deg * var(--number-of-spins)));
      }
      .line-2 {
        opacity: 0;
      }
      .line-3 {
        transform: translateY(
            calc(-1 * (var(--button-height) / 2 - var(--line-thickness) / 2))
          )
          rotate(calc(45deg * var(--number-of-spins)));
      }
    }
  }

  /* Hamburger Menu
    ---------------------------------- */
  .ui-hamburger-menu {
    position: fixed;
    right: 0;
    top: 4rem;
    bottom: 0;
    z-index: 90;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgb(255 255 255 / 0.08);
    transition:
      transform 120ms ease-in-out,
      visibility 0s 120ms;
    transform: translateX(100%);
    overflow-y: auto;
    visibility: hidden;

    /* Show menu when hamburger is open */
    [data-ui-hamburger-open-value="true"] & {
      visibility: visible;
      transform: translateX(0);
      transition:
        transform 120ms ease-in-out,
        visibility 0s 0s;
    }

    /* Never show on desktop */
    @media (min-width: 56.01rem) { /* above --bp-lg */
      display: none !important;
    }
  }

  /* Avatar
  ---------------------------------- */
  .ui-avatar {
    /* Default size fallback — helper always sets data-size, but just in case */
    --avatar-size: 2.5rem;
    --initials-font-size: 1rem;

    &[data-size="sm"] {
      --avatar-size: 1.5rem;
      --initials-font-size: 0.9375rem;
    }

    /* Medium is the default */
    &[data-size="md"] {
      --avatar-size: 2.5rem;
      --initials-font-size: 1rem;
    }

    &[data-size="lg"] {
      --avatar-size: 7.5rem;
      --initials-font-size: 3rem;
    }

    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: var(--rounded-full);
    background: var(--brand-1);          /* Navy — initials background */
    outline: var(--border-lg) solid var(--white);
    color: var(--white);
    overflow: hidden;
    box-shadow: var(--shadow);

    .initials {
      font-size: var(--initials-font-size);
      font-weight: var(--font-semibold);
      line-height: 1;
    }
  }

  /* Toast
  ---------------------------------- */
  .ui-toast {
    position: fixed;
    display: flex;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    align-items: center;
    gap: var(--space-xs);
    min-width: 24rem;
    padding: var(--space-sm) var(--space-sm);
    border-radius: var(--rounded);
    box-shadow: var(--shadow);
    background: var(--darker);
    color: var(--light);
    border-left: 0.375rem solid;
    animation: ephemeral 8s both;
    view-transition-name: ui-toast; /* own compositing layer, excluded from root page crossfade */

    svg {
      flex-shrink: 0;
      border-radius: 50%;
    }

    span {
      flex: 1;
    }

    .ui-toast-close {
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      border-radius: 100%;
      width: 1.6rem;
      height: 1.6rem;

      &:hover {
        color: var(--white);
        background-color: var(--black);
      }
    }

    &.ui-toast-success {
      border-left-color: var(--success);

      svg.icon {
        color: var(--success);
      }
    }

    &.ui-toast-error {
      border-left-color: var(--error);

      svg.icon {
        color: var(--error);
      }
    }
  }

  /* Dropdown
  ---------------------------------- */
  .ui-dropdown {
    position: relative;
    display: inline-block;

    menu,
    ul {
      position: absolute;
      top: 100%;
      right: 0;
      z-index: 100;
      min-width: 12rem;
      margin-top: var(--space-2xs);
      padding: var(--space-2xs);
      background: var(--white);
      border-radius: var(--rounded);
      box-shadow: var(--shadow);
      list-style: none;
      opacity: 0;
      visibility: hidden;
      transform: translateY(-0.5rem);
      transition:
        opacity 150ms ease-in-out,
        transform 150ms ease-in-out,
        visibility 0s 150ms;

      li {
        margin: 0;
      }

      a,
      button {
        display: flex;
        align-items: center;
        gap: var(--space-2xs);
        width: 100%;
        padding: var(--space-2xs) var(--space-xs);
        border-radius: var(--rounded-sm);
        text-decoration: none;
        color: var(--darker);
        background: transparent;
        border: none;
        cursor: pointer;
        transition: background-color 100ms ease;

        &:hover {
          background-color: var(--lighter);
        }
      }
    }

    /* Show menu when dropdown is open */
    &.is-open menu,
    &.is-open ul {
      opacity: 1;
      visibility: visible;
      transform: translateY(0);
      transition:
        opacity 150ms ease-in-out,
        transform 150ms ease-in-out,
        visibility 0s 0s;
    }
  }

  /* Auth Verify OTP Input
  ---------------------------------- */
  .ui-auth-verify {
    display: flex;
    justify-content: center;

    .ui-auth-verify-digits {
      display: flex;
      gap: var(--space-xs);

      input {
        width: 3rem;
        height: 3.5rem;
        padding: 0;
        font-size: 1.5rem;
        font-weight: 700;
        text-align: center;
        border: var(--border-lg) solid var(--light);
        border-radius: var(--rounded);
        background: var(--white);
        color: var(--darker);
        transition:
          border-color 150ms ease,
          box-shadow 150ms ease;

        &:focus {
          outline: none;
          border-color: var(--brand-1);
          box-shadow: 0 0 0 3px
            color-mix(in srgb, var(--brand-1) 20%, transparent);
        }

        &::placeholder {
          color: var(--midtone);
        }
      }
    }
  }

  /* Modal
  ---------------------------------- */
  .ui-modal {
    border: none;
    border-radius: var(--rounded-md);
    padding: var(--space-sm);
    margin: auto;
    width: min(var(--max-w-form), calc(100vw - (var(--space-sm) * 2)));
    max-width: 100%;
    max-height: min(90vh, 52rem);
    overflow: hidden;
    color: var(--dark);
    background: var(--white);
    box-shadow: var(--shadow-lg);

    &.modal-sm { width: min(24rem,   calc(100vw - (var(--space-sm) * 2))); }
    &.modal-lg { width: min(52rem,   calc(100vw - (var(--space-sm) * 2))); }
    &.modal-xl { width: min(68rem,   calc(100vw - (var(--space-sm) * 2))); }
  }

  .ui-modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
  }

  .ui-modal[open] {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .ui-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: var(--space-sm);
    border-bottom: var(--border) solid var(--light);
    flex-shrink: 0;
  }

  /* Pure scroll container — no padding; header/actions own the breathing room */
  .ui-modal__body {
    overflow-y: auto;
    flex: 1;
  }

  /* Optional sticky action bar at the bottom of a modal form */
  .ui-modal__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    border-top: var(--border) solid var(--light);
    padding-top: var(--space-sm);
    flex-shrink: 0;
  }

  /* Breadcrumb */
  .ui-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2xs);
    font-size: var(--text-sm);
    padding: var(--space-2xs) 0;
  }

  .ui-breadcrumb-item {
    padding-left: var(--space-2xs);
    color: var(--midtone);
    display: flex;
    gap: var(--space-xs);
  }

  .ui-breadcrumb-item:first-child {
    padding-left: 0;
  }

  .ui-breadcrumb-item a {
    text-decoration: none;
    color: var(--midtone);
    display: flex;
    gap: var(--space-xs);
  }

  .ui-breadcrumb-item.active {
    color: var(--brand-2);
  }

  .ui-breadcrumb-item a,
  .ui-breadcrumb-item.active {
    line-height: 1;
    align-items: center;
  }

  .ui-breadcrumb-item a:hover {
    text-decoration: underline;
  }

  /* separator slash after each link */
  .ui-breadcrumb-item + .ui-breadcrumb-item::before {
    content: "/";
    margin-right: var(--space-2xs);
    color: var(--midtone);
    pointer-events: none;
    font-size: 1rem;
  }
}

/* ── Smart search spotlight overlay ─────────────────────────────────────── */

.ui-search-floating {
  position: fixed !important;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  width: 540px;
  max-width: 92vw;
  z-index: 50;
  background: var(--surface, #fff);
  border-radius: var(--radius-lg, 0.75rem);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: var(--space-sm, 0.75rem);
  animation: ui-search-drop-in 0.15s ease-out;
}


@keyframes ui-search-drop-in {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.96) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1) translateY(0);
  }
}
