:root {
  /* Brand colours */
  --color-navy: #071f4a;
  --color-navy-light: #0d2d61;
  --color-gold: #f6cc4f;
  --color-gold-hover: #e3b936;
  --color-snooker-green: #05611d;
  --color-snooker-green-hover: #044d18;
  --color-cream: #f7f2d8;
  --color-ball-red: #e41109;
  --color-ball-red-hover: #bd0d07;

  /* Text */
  --color-white: #ffffff;
  --color-text: #172033;
  --color-muted: #4b5563;
  --color-subtle: #6b7280;

  /* Existing selectors retained for compatibility */
  --color-page-label: var(--color-navy);
  --color-emerald: var(--color-navy);
  --color-emerald-dark: var(--color-navy-light);
  --color-download: var(--color-navy);
  --color-download-hover: var(--color-navy-light);
  --color-register: var(--color-ball-red);

  /* Page and component surfaces */
  --color-page-background: #f5f6f2;
  --color-surface: var(--color-white);
  --color-surface-muted: #f1f3ef;
  --color-surface-hover: var(--color-cream);

  /* Borders */
  --color-border: #dfe3dc;
  --color-border-strong: #c8cec4;

  /* Shape */
  --radius-xs: 0.25rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-pill: 9999px;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;

  /* Animation */
  --duration-fast: 0.2s;
  --duration-base: 0.3s;

  /* Shadows */
  --shadow-card:
    0 1px 2px rgb(7 31 74 / 0.08),
    0 1px 4px rgb(7 31 74 / 0.04);

  --shadow-raised:
    0 4px 12px rgb(7 31 74 / 0.14);

  --shadow-focus:
    0 0 0 3px rgb(246 204 79 / 0.55),
    0 4px 12px rgb(7 31 74 / 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: clamp(16px, 15.3px + 0.22vw, 18px);
  text-size-adjust: 100%;
}

body {
  min-width: 20rem;
  overflow-x: clip;
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  line-height: 1.55;
}

html.overlay-open,
body.overlay-open {
  overflow: hidden;
  height: 100%;
}

#overlayWrapper {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: rgb(7 18 38 / 0.62);
  backdrop-filter: blur(4px);
}

#overlayWrapper:not(.hidden) {
  display: flex;
}

#overlayWrapper > div {
  position: relative;
  width: min(80vw, 32rem);
  height: min(80vh, 37rem);
  max-height: 90vh;
  max-height: 90dvh;
  overflow: hidden;
  border-radius: 1rem;
  box-shadow: 0 1.5rem 4rem rgb(7 18 38 / 0.35);
}

#dynamicFrame {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: inherit;
  display: block;
}

@media (max-width: 30rem) {
  #overlayWrapper {
    padding: 0.35rem;
  }

  #overlayWrapper > div {
    width: 100%;
    max-height: calc(100dvh - 0.7rem);
  }

  #closeOverlayBtn.overlay-close-btn {
    top: 0.45rem;
    right: 0.45rem;
  }
}

#closeOverlayBtn.overlay-close-btn {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: 1px solid rgb(148 163 184 / 0.35);
  z-index: 2;
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 0.96);
  color: #0f172a;
  box-shadow: 0 10px 24px rgb(15 23 42 / 0.18);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    color 140ms ease,
    background-color 140ms ease;
}

#closeOverlayBtn.overlay-close-btn svg {
  width: 1.1rem;
  height: 1.1rem;
  pointer-events: none;
}

#closeOverlayBtn.overlay-close-btn:hover {
  color: #b91c1c;
  background: rgb(255 255 255 / 0.98);
  box-shadow: 0 14px 28px rgb(15 23 42 / 0.24);
  transform: translateY(-1px);
}

#closeOverlayBtn.overlay-close-btn:active {
  transform: translateY(0);
}

#closeOverlayBtn.overlay-close-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/****************************************************************************************************/
/* Section headings */
/****************************************************************************************************/
.section-heading {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  line-height: 1.3;
  font-weight: 600;
  margin-bottom: 0.75rem;
  text-align: center;
}

.subheading {
  font-size: clamp(1.125rem, 3vw, 1.375rem);
  line-height: 1.4;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-align: center;
}

/* ============================
   GO TO TOP BUTTON
   ============================ */
#goTopBtn {
    --go-top-y: 8px;
    --go-top-scale: 1;

    position: fixed;
    right: 1.5rem;
    bottom: 3.75rem;
    z-index: 99;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 3rem;
    height: 3rem;
    padding: 0;

    color: var(--color-navy, #071f4a);
    font-size: 1.25rem;

    background: var(--color-gold, #f6cc4f);
    border: 2px solid var(--color-navy, #071f4a);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgb(7 31 74 / 0.25);

    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform:
        translateY(var(--go-top-y))
        scale(var(--go-top-scale));

    transition:
        opacity 0.4s ease,
        visibility 0.4s ease,
        transform 0.25s ease,
        color 0.2s ease,
        background-color 0.2s ease;
}

#goTopBtn.show {
    --go-top-y: 0;

    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#goTopBtn.show:hover {
    --go-top-y: -4px;

    color: var(--color-gold, #f6cc4f);
    background: var(--color-navy, #071f4a);
    border-color: var(--color-gold, #f6cc4f);
}

#goTopBtn.show:active {
    --go-top-scale: 0.92;
}

#goTopBtn:focus-visible {
    outline: 3px solid rgb(246 204 79 / 0.6);
    outline-offset: 3px;
}

@media (max-width: 39.999rem) {
    #goTopBtn {
        right: 1rem;
        bottom: 1rem;
        width: 2.75rem;
        height: 2.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    #goTopBtn {
        transition: none;
    }
}

/****************************************************************************************************/
/* Headings */
/****************************************************************************************************/
.page-heading {
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  line-height: 1.2;
  font-weight: 700;
  margin-bottom: 0;
  text-align: center;
}

/****************************************************************************************************/
/* Other */
/****************************************************************************************************/
.lastupdated {
  font-size: 0.8125rem;
  line-height: 1.25;
  text-align: center;
  font-style: italic;
  color: var(--color-subtle);
  margin-bottom: 1.5rem;
}

/****************************************************************************************************/
/* Inpage Headers */
/****************************************************************************************************/
.inpage-header,
.season-label {
  display: block;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-page-label);
  font-weight: 600;
  margin-bottom: 0.55rem;
  font-size: clamp(0.75rem, 2vw, 1.125rem);
}

.inpage-header {
  padding-top: 0.55rem;
}

.season-label {
  padding-top: 0.25rem;
}

.inpage-small {
  display: block;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-page-label);
  font-weight: 600;
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border-strong);
}

/****************************************************************************************************/
/* Season Select */
/****************************************************************************************************/
.season-wrapper {
  position: relative;
}

.season-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  padding: 0.65rem 2.5rem 0.65rem 0.75rem;
  font-size: clamp(0.875rem, 2vw, 1rem);
  font-weight: 500;
  color: var(--color-text);
  background-color: var(--color-white);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='none' stroke='%236b7280' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8l4 4 4-4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  transition:
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    background-color var(--duration-fast) ease;
}

.season-select:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-emerald);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}

.season-select:focus-visible {
  outline: none;
  border-color: var(--color-emerald-dark);
  box-shadow: 0 0 0 2px rgb(5 150 105 / 0.4);
}

.season-select-text {
  display: block;
  font-size: clamp(0.875rem, 2vw, 1rem);
  color: var(--color-muted);
  margin-bottom: 0.35rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* Handicaps club shortcuts */
.club-shortcuts {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border-strong);
}

.club-shortcuts__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0 0.125rem;
}

.club-shortcuts__link {
  display: block;
  flex: 0 0 auto;
  min-width: 4.5rem;
  padding: 0.5rem 0.65rem;
  color: var(--color-text);
  background-color: var(--color-white);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
  transition:
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    background-color var(--duration-fast) ease;
}

.club-shortcuts__link:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-emerald);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}

.club-shortcuts__link:focus-visible {
  outline: none;
  border-color: var(--color-emerald-dark);
  box-shadow: 0 0 0 2px rgb(5 150 105 / 0.4);
}

/****************************************************************************************************/
/* Containers */
/****************************************************************************************************/
.my-fluid-text {
  font-size: clamp(0.875rem, 2vw, 1rem);
  line-height: 1.25;
}

.card-container,
.download-card {
  background-color: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-3);
  overflow-x: auto;
}

.section-box {
  width: 100%;
  max-width: 72rem;
  margin-right: auto;
  margin-left: auto;
  padding: 0.55rem var(--space-3) var(--space-3);
}

.season-promotion {
  width: min(86vw, 24rem);
}

.season-promotion img {
  display: block;
  width: 100%;
  height: auto;
}

/****************************************************************************************************/
/* Fixtures Month Navigation */
/****************************************************************************************************/
#monthContainer::-webkit-scrollbar {
  height: 6px;
}

#monthContainer::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

#monthContainer::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

#monthContainer::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.month-section {
  transition: opacity 0.3s ease-in-out;
}

.month-section.hidden {
  display: none;
}

.month-btn {
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease-in-out;
  flex: 1 1 0;
  min-width: 3rem;
  padding: 0.4rem 0.5rem;
  border: 2px solid #d1d5db;
  border-radius: 0.5rem;
  font-weight: 700;
  line-height: 1.05;
  white-space: nowrap;
  color: #374151;
  font-size: 0.58rem;
}

.month-btn:hover {
  background-color: #f3f4f6;
}

.month-btn.active {
  background-color: #dc2626;
  color: white;
  border-color: #dc2626;
}

.month-btn .month-label {
  font-size: 0.55rem;
  line-height: 1;
}

.month-btn .month-year {
  font-size: 0.8rem;
  line-height: 1;
  font-weight: 700;
}

@media (min-width: 640px) {
  .month-btn {
    min-width: 4.25rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }

  .month-btn .month-label {
    font-size: 0.75rem;
  }

  .month-btn .month-year {
    font-size: 0.95rem;
  }
}

@media (min-width: 1024px) {
  .month-btn {
    min-width: 6rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  .month-btn .month-label {
    font-size: 0.875rem;
  }

  .month-btn .month-year {
    font-size: 1rem;
  }
}

/****************************************************************************************************/
/* Countdown */
/****************************************************************************************************/
.cvsl-pulse-scale {
  animation: cvsl-pulse-scale 1s infinite;
}

@keyframes cvsl-pulse-scale {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

/****************************************************************************************************/
/* Grids */
/****************************************************************************************************/
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.card-grid > * {
  min-width: 0;
}

@media (min-width: 640px) {
    .card-grid--thirds {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1rem;
    }

    .card-grid--halves {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
    }
}

/****************************************************************************************************/
/* Competition Cards */
/****************************************************************************************************/
:is(.competition-link, .notification-link) {
  display: block;
  text-decoration: none;
}

:is(.competition-link, .notification-link):focus-visible {
  outline: none;
}

:is(.competition, .competitionNoHover, .notification, .notificationNoHover) {
  position: relative;
  overflow: hidden;
  margin-bottom: var(--space-4);
  background-color: var(--color-white);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-raised);
  transition:
    border-color var(--duration-base) ease,
    box-shadow var(--duration-base) ease,
    transform var(--duration-base) ease;
}

:is(.competition, .notification):hover {
  border-color: var(--color-emerald);
  transform: translateY(-2px);
}

:is(.competition, .notification):active,
.club-card:active {
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.08);
}

:is(.competition, .notification):focus-visible,
.competition-link:focus-visible .competition,
.notification-link:focus-visible .notification {
  outline: none;
  background: var(--color-surface-muted);
  box-shadow: var(--shadow-focus);
  transform: translateY(-2px) scale(1.03);
}

:is(.competition-content, .notification-content) {
  padding: var(--space-6);
  font-size: clamp(0.875rem, 2vw, 1rem);
  line-height: 1.625;
  color: var(--color-muted);
}

:is(.competition-content, .notification-content) h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  line-height: 1.4;
  font-weight: 600;
  margin-bottom: var(--space-2);
  text-align: center;
}

:is(.competition-content, .notification-content) p {
  margin-bottom: var(--space-2);
}

:is(.competition-content, .notification-content) ul {
  font-size: clamp(0.875rem, 2vw, 1rem);
  list-style-type: disc;
  list-style-position: inside;
  line-height: 1.6;
  color: var(--color-muted);
  padding-left: 0;
  margin-top: var(--space-2);
  margin-bottom: var(--space-4);
}

:is(.competition-content, .notification-content) li {
  margin-bottom: var(--space-2);
}

.register-badge {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  color: var(--color-white);
  background-color: var(--color-register);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: clamp(0.75rem, 1.5vw, 0.875rem);
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.2);
}

/****************************************************************************************************/
/* Downloads */
/****************************************************************************************************/
.download-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.download-card p {
  font-size: clamp(0.875rem, 2vw, 1rem);
  text-align: center;
  line-height: 1.5;
  color: var(--color-muted);
  font-weight: 500;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem var(--space-3);
  color: var(--color-white);
  background-color: var(--color-download);
  border-radius: calc(var(--radius-sm) - 0.125rem);
  font-size: clamp(0.75rem, 1.5vw, 0.875rem);
  text-decoration: none;
  transition:
    background-color var(--duration-base) ease,
    box-shadow var(--duration-fast) ease;
}

.download-btn:hover {
  background-color: var(--color-download-hover);
}

.download-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.download-btn svg {
  width: 1rem;
  height: 1rem;
}

/****************************************************************************************************/
/* Brand utility compatibility — keeps the existing generated Tailwind bundle on the new palette. */
/****************************************************************************************************/
.text-navy { color: var(--color-navy) !important; }
.bg-navy { background-color: var(--color-navy) !important; }
.bg-off-white { background-color: var(--color-page-background) !important; }
.text-emerald-600,
.text-emerald-700 { color: var(--color-navy) !important; }
.border-emerald-600 { border-color: var(--color-navy) !important; }
.hover\:border-emerald-600:hover { border-color: var(--color-gold) !important; }
.bg-emerald-50 { background-color: var(--color-cream) !important; }
.bg-sky-200 { background-color: var(--color-cream) !important; }
.border-sky-300 { border-color: var(--color-gold) !important; }
.text-slate-900,
.text-slate-800 { color: var(--color-navy) !important; }
.text-slate-700,
.text-gray-600 { color: var(--color-muted) !important; }

/****************************************************************************************************/
/* Media */
/****************************************************************************************************/
.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  color: var(--color-navy);
  background: var(--color-gold);
  border: 2px solid var(--color-navy);
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(calc(-100% - 1rem));
  transition: transform var(--duration-fast) ease;
}

.skip-link:focus {
  outline: 3px solid var(--color-white);
  outline-offset: 2px;
  transform: translateY(0);
}

#goTopBtn svg {
  width: 1rem;
  height: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
