:root {
  --gs-gutter: 0.75rem;
  --gs-gutter-sm: 0.5rem;
}

/* Responsive overrides for /global-stats */

/* Recent conversions card layout improvements */

/* Target the Recent Global Conversions grid used inside the Aim Sensitivity section */
div[style*="minmax(280px"] {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
  gap: 1rem !important;
  width: 100% !important;
}

div[style*="minmax(280px"] > * {
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  gap: 0.5rem !important;
}

div[style*="minmax(280px"] > * .name,
div[style*="minmax(280px"] > * .score,
div[style*="minmax(280px"] > * span,
div[style*="minmax(280px"] > * div {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  max-width: 100% !important;
}

div[style*="minmax(280px"] > * .score {
  font-size: 0.9rem !important;
}

/* Mobile: show recent conversion cards in a compact multi-column grid */
@media (max-width: 768px) {
  div[style*="minmax(280px"] {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
    gap: 0.75rem !important;
  }

  div[style*="minmax(280px"] > * {
    padding: 10px 12px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
    gap: 0.35rem !important;
  }

  div[style*="minmax(280px"] > * .name {
    font-size: 0.8rem !important;
    line-height: 1.3 !important;
  }

  div[style*="minmax(280px"] > * .score {
    font-size: 0.7rem !important;
  }
}

/* Very small devices: keep cards readable */
@media (max-width: 360px) {
  div[style*="minmax(280px"] {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    gap: 0.5rem !important;
  }

  div[style*="minmax(280px"] > * {
    padding: 8px 10px !important;
    border-radius: 10px !important;
  }

  div[style*="minmax(280px"] > * .name {
    font-size: 0.75rem !important;
  }

  div[style*="minmax(280px"] > * .score {
    font-size: 0.65rem !important;
  }
}

/* Global layout fixes - prevent any horizontal scroll/clip */
html, body {
  overflow-x: hidden !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
}

*, *::before, *::after {
  box-sizing: inherit !important;
}

/* Make sure media doesn't break layout */
img, iframe, video, canvas {
  max-width: 100% !important;
  height: auto !important;
}

svg {
  max-width: 100% !important;
}

/* Desktop defaults: keep original layout mostly intact */
[class*="sc-e27358be-0"] {
  max-width: 1200px !important;
  width: 100% !important;
}

[class*="sc-14102aaa-0"] {
  max-width: 1200px !important;
  width: 100% !important;
}

body > div {
  max-width: 100% !important;
}

/* Mobile */
@media (max-width: 768px) {
  /* Main wrapper: full width on small screens */
  [class*="sc-e27358be-0"] {
    max-width: 100% !important;
    width: 100% !important;
    padding: 16px var(--gs-gutter) !important;
  }

  /* Force wrapping on all text inside global-stats */
  [class*="sc-e27358be"] h1,
  [class*="sc-e27358be"] h2,
  [class*="sc-e27358be"] h3,
  [class*="sc-e27358be"] p,
  [class*="sc-e27358be"] span,
  [class*="sc-e27358be"] div,
  [class*="sc-e27358be"] a,
  [class*="sc-e27358be"] button {
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    white-space: normal !important;
    hyphens: auto !important;
    max-width: 100% !important;
  }

  /* Keep numbers from breaking weirdly */
  [class*="sc-e27358be"] .val,
  [class*="sc-e27358be"] .score {
    word-break: normal !important;
    overflow-wrap: anywhere !important;
  }

  /* Keep grid/flex children from forcing overflow */
  [class*="sc-e27358be"] > *,
  [class*="sc-e27358be"] > * > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  [class*="sc-e27358be-1"] {
    margin-bottom: 1.5rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  [class*="sc-e27358be-1"] h1 {
    font-size: clamp(1.4rem, 7vw, 2rem) !important;
    letter-spacing: -0.5px !important;
    line-height: 1.2 !important;
    margin-bottom: 0.75rem !important;
    text-align: center !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  [class*="sc-e27358be-1"] p {
    font-size: 0.9rem !important;
    padding: 0 !important;
    line-height: 1.5 !important;
    text-align: center !important;
  }

  /* Time range selector: wrap, no horizontal scroll */
  [class*="sc-e27358be-10"] {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    margin: 1rem 0 1.25rem 0 !important;
    gap: 0.35rem !important;
    overflow-x: visible !important;
    padding-bottom: 0 !important;
    width: 100% !important;
  }

  [class*="sc-e27358be-11"] {
    padding: 8px 14px !important;
    font-size: 0.8rem !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    text-align: center !important;
  }

  /* Category tabs: stack vertically */
  [class*="sc-e27358be-2"] {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 12px !important;
    padding: 8px !important;
    gap: 0.35rem !important;
    margin-bottom: 1.5rem !important;
  }

  [class*="sc-e27358be-3"] {
    width: 100% !important;
    padding: 10px 12px !important;
    font-size: 0.85rem !important;
    border-radius: 8px !important;
    text-align: center !important;
    flex: none !important;
  }

  /* Stats grid */
  [class*="sc-e27358be-4"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    margin-bottom: 1.5rem !important;
    width: 100% !important;
  }

  [class*="sc-e27358be-5"] {
    padding: 1rem !important;
    border-radius: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  [class*="sc-e27358be-5"] .val {
    font-size: 1.75rem !important;
    line-height: 1.1 !important;
  }

  [class*="sc-e27358be-5"] .label {
    font-size: 0.65rem !important;
  }

  [class*="sc-e27358be-5"] .subval {
    font-size: 0.75rem !important;
  }

  /* Two-column telemetry layout */
  [class*="sc-e27358be-6"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }

  [class*="sc-e27358be-7"] {
    padding: 1rem !important;
    border-radius: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }

  [class*="sc-e27358be-7"] h3 {
    font-size: 0.9rem !important;
    margin-bottom: 0.75rem !important;
    text-align: left !important;
  }

  /* Telemetry values */
  [class*="sc-e27358be-7"] div {
    font-size: 0.9rem !important;
    line-height: 1.4 !important;
  }

  [class*="sc-e27358be-7"] svg,
  [class*="sc-e27358be-7"] canvas {
    max-width: 100% !important;
    display: block !important;
  }

  [class*="sc-e27358be-7"] canvas {
    height: auto !important;
  }

  /* Leaderboard rows */
  [class*="sc-e27358be-8"] {
    grid-template-columns: 24px 1fr auto !important;
    padding: 8px 10px !important;
    gap: 6px !important;
    align-items: start !important;
    width: 100% !important;
  }

  [class*="sc-e27358be-8"] .rank {
    font-size: 0.9rem !important;
    line-height: 1.4 !important;
  }

  [class*="sc-e27358be-8"] .name {
    font-size: 0.8rem !important;
    line-height: 1.4 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  [class*="sc-e27358be-8"] .score {
    font-size: 0.7rem !important;
    padding: 3px 6px !important;
    white-space: nowrap !important;
  }

  /* Loading state */
  [class*="sc-e27358be-9"] {
    padding: 1.5rem 0.75rem !important;
    font-size: 0.9rem !important;
  }

  /* Section headings */
  [class*="sc-e27358be-13"] {
    font-size: 1rem !important;
    margin-bottom: 1rem !important;
    text-align: left !important;
    width: 100% !important;
  }

  /* Failure/device cards grid */
  [class*="sc-e27358be-12"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }

  [class*="sc-e27358be-12"] > * {
    padding: 0.875rem !important;
    border-radius: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Loading spinner */
  [class*="sc-e27358be-14"] {
    width: 64px !important;
    height: 64px !important;
  }

  [class*="sc-e27358be-14"]::before {
    width: 48px !important;
    height: 48px !important;
  }

  [class*="sc-e27358be-14"] span {
    font-size: 0.9rem !important;
  }
}

/* Very small devices */
@media (max-width: 360px) {
  :root {
    --gs-gutter: 0.5rem;
  }

  [class*="sc-e27358be-0"] {
    padding: 12px var(--gs-gutter) !important;
  }

  [class*="sc-e27358be-1"] h1 {
    font-size: 1.25rem !important;
  }

  [class*="sc-e27358be-1"] p {
    font-size: 0.85rem !important;
  }

  [class*="sc-e27358be-3"],
  [class*="sc-e27358be-11"] {
    padding: 8px 10px !important;
    font-size: 0.75rem !important;
  }

  [class*="sc-e27358be-5"] .val {
    font-size: 1.5rem !important;
  }

  [class*="sc-e27358be-7"] div {
    font-size: 0.85rem !important;
  }

  [class*="sc-e27358be-8"] {
    grid-template-columns: 20px 1fr auto !important;
    padding: 6px 8px !important;
  }

  [class*="sc-e27358be-8"] .rank {
    font-size: 0.8rem !important;
  }

  [class*="sc-e27358be-8"] .name {
    font-size: 0.75rem !important;
  }

  [class*="sc-e27358be-8"] .score {
    font-size: 0.65rem !important;
    padding: 2px 5px !important;
  }

  [class*="sc-e27358be-13"] {
    font-size: 0.9rem !important;
  }
}
