
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-y: scroll; /* Prevent content jumping */
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-smooth: always;
  -webkit-font-feature-settings: "liga", "kern";
  font-feature-settings: "liga", "kern";
  overscroll-behavior-y: contain; /* Prevent pull-to-refresh */
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  overflow-x: hidden;
}

/* Remove 300ms tap delay on mobile */
a, button, input, select, textarea {
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

/* Smooth scrolling for all browsers */
@media (prefers-reduced-motion: no-preference) {
  :root {
    scroll-behavior: smooth;
  }
}

/* iOS Safari fixes */
input, textarea, select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 0;
}

input[type="search"] {
  -webkit-appearance: textfield;
  appearance: textfield;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* Prevent zoom on iOS when focusing inputs */
@media screen and (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Fix for input zoom on iOS Safari */
@supports (-webkit-touch-callout: none) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="number"],
  textarea {
    font-size: 16px;
  }
}

/* Flexbox fallbacks for all browsers */
.flex {
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
}

.flex-col {
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  -moz-box-orient: vertical;
  -moz-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
}

.flex-center {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  
  -webkit-box-pack: center;
  -moz-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  
  -webkit-box-align: center;
  -moz-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
}

/* Grid fallbacks */
.grid {
  display: -ms-grid;
  display: grid;
}

/* CSS Grid IE11 fallback */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  .grid {
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
  }
  
  .grid > * {
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
  }
}

/* Transform & Animation prefixes */
.animated {
  -webkit-animation-duration: 1s;
  -moz-animation-duration: 1s;
  -o-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  -moz-animation-fill-mode: both;
  -o-animation-fill-mode: both;
  animation-fill-mode: both;
}

/* Backdrop Filter fallback */
.backdrop-blur {
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

@supports not (backdrop-filter: blur(10px)) {
  .backdrop-blur {
    background-color: rgba(0, 0, 0, 0.7);
  }
}

/* CSS Variables fallback for older browsers */
@supports not (--css: variables) {
  :root {
    background: #0b0f1e;
    color: #EAF0FF;
  }
}

/* Sticky positioning with vendor prefixes */
.sticky {
  position: -webkit-sticky;
  position: sticky;
}

@supports not (position: sticky) {
  .sticky {
    position: fixed;
  }
}

/* Object-fit fallback */
@supports not (object-fit: cover) {
  img {
    max-width: 100%;
    height: auto;
  }
}

/* User-select browser compatibility */
.no-select,
button, .btn, .pill, .tag {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Fix for 100vh on mobile browsers (iOS Safari fix) */
.full-height {
  height: 100vh;
  height: 100dvh;
  height: 100svh;
}

@supports (-webkit-touch-callout: none) {
  .full-height {
    height: -webkit-fill-available;
  }
}

/* Safe area insets for notched devices (iPhone X+) */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
  
  .topbar {
    padding-top: max(12px, env(safe-area-inset-top));
  }
}

/* Touch-friendly clickable areas (minimum 44x44px) */
@media (hover: none) and (pointer: coarse) {
  button, a, [role="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
  }
  
  .btn {
    min-height: 44px;
    padding: 12px 20px;
  }
}

/* Button appearance normalization */
button {
  -webkit-appearance: button;
  -moz-appearance: button;
  appearance: button;
  background: none;
  border: none;
  cursor: pointer;
}

button::-moz-focus-inner {
  border: 0;
  padding: 0;
}

/* Smooth transitions with vendor prefixes */
.transition {
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
}

/* Safari-specific fixes */
@media not all and (min-resolution:.001dpcm) {
  @supports (-webkit-appearance:none) {
    .safari-fix, img, .pcard, .cardbox {
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
    }
  }
}

/* Firefox-specific fixes */
@-moz-document url-prefix() {
  .firefox-fix {
    image-rendering: -moz-crisp-edges;
  }
}

/* Edge-specific fixes */
@supports (-ms-ime-align: auto) {
  .edge-fix {
    overflow-x: hidden;
  }
}

/* Fix for modal/overlay scroll on mobile */
.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Optimize for GPU acceleration and performance */
.gpu-accelerated,
.pcard, .btn, .modal, .topbar {
  -webkit-transform: translateZ(0);
  -moz-transform: translateZ(0);
  -ms-transform: translateZ(0);
  -o-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
}

/* Focus visible for accessibility */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--brand1, #ff4fd8);
  outline-offset: 2px;
}

/* Image optimization for better rendering */
img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  max-width: 100%;
  height: auto;
}

/* Better scrollbar styling (Webkit browsers) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Firefox scrollbar styling */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Prevent horizontal scroll on all elements */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

/* Fix for landscape orientation on mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .topbar {
    min-height: 50px;
  }
  
  .authCard {
    max-height: 90vh;
    overflow-y: auto;
  }
}

/* High DPI display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  img {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Print styles */
@media print {
  .bg-float, .emoji-orbit, .orb {
    display: none !important;
  }
}
