:root {
  /* Enhanced color palette - extends theme.css */
  --canvas-white: #f8f9fa;
  --paper-cream: #fefefe;
  --ink-black: #1a1a1a;
  --forest-green: #2d5016;
  --clay-red: #a0522d;
  --rust-orange: #cd853f;
  --deep-purple: #483d8b;
  --midnight-blue: #191970;
  --text-medium: #4a4a4a;
  --text-muted: #6c6c6c;
  --border-color: #d1d5db;
  --shadow: 0 4px 20px rgba(44, 44, 44, 0.1);
  --gradient-earth: linear-gradient(135deg, var(--forest-green), var(--sage-green));
  --gradient-clay: linear-gradient(135deg, var(--clay-red), var(--rust-orange));
  --gradient-mystical: linear-gradient(135deg, var(--deep-purple), var(--lavender));
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html {
  /* Prevent text size adjustment on orientation change */
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  /* Smooth scrolling on iOS */
  -webkit-overflow-scrolling: touch;
  /* Prevent overscroll bounce */
  overscroll-behavior: none;
}

body {
  font-family: 'Quicksand', sans-serif;
  background: var(--canvas-white);
  background-image:
    radial-gradient(circle at 15% 25%, rgba(45, 80, 22, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 85% 15%, rgba(72, 61, 139, 0.06) 0%, transparent 55%),
    radial-gradient(circle at 70% 80%, rgba(160, 82, 45, 0.05) 0%, transparent 65%),
    radial-gradient(circle at 30% 70%, rgba(218, 165, 32, 0.04) 0%, transparent 50%);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* iOS Safe Area Support */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  margin-bottom: 1rem;
  background: var(--gradient-earth);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  width: 100%;
}

.navbar {
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.98), rgba(254, 254, 254, 0.95));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(135, 169, 107, 0.2);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.nav-brand a {
  font-family: 'Playfair Display', serif;
  font-size: 1.75rem;
  font-weight: 900;
  text-decoration: none;
  background: linear-gradient(135deg, #2d5016 0%, #87a96b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  transition: transform 0.3s ease;
}

.nav-brand a:hover {
  transform: scale(1.05);
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
  padding: 0;
}

.nav-menu li {
  margin: 0;
  padding: 0;
}

.nav-menu a {
  color: #4a4a4a;
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  display: inline-block;
}

.nav-menu a:hover {
  color: var(--sage-green);
  background: rgba(135, 169, 107, 0.08);
}

/* Remove underline effect for cleaner look */
.nav-menu a::after {
  display: none;
}

.nav-menu .btn-primary {
  background: linear-gradient(135deg, #2d5016, #87a96b);
  color: white !important;
  padding: 0.65rem 1.5rem !important;
  border-radius: 50px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(45, 80, 22, 0.2);
  border: none;
  margin-left: 0.5rem;
}

.nav-menu .btn-primary:hover {
  color: white !important;
  background: linear-gradient(135deg, #3a6a1e, #95b778);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(45, 80, 22, 0.3);
}

.nav-menu .btn-primary::after {
  display: none;
}

/* Style for Dashboard and Admin buttons in navbar */
.nav-menu .dashboard-btn,
.nav-menu .admin-btn {
  background: linear-gradient(135deg, #87a96b, #a5c490);
  color: white !important;
  padding: 0.65rem 1.5rem !important;
  border-radius: 50px;
  font-weight: 600;
  margin-left: 0.5rem;
  box-shadow: 0 2px 10px rgba(135, 169, 107, 0.3);
}

.nav-menu .admin-btn {
  background: linear-gradient(135deg, #daa520, #f4d03f);
  box-shadow: 0 2px 10px rgba(218, 165, 32, 0.3);
}

.nav-menu .dashboard-btn:hover,
.nav-menu .admin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(45, 80, 22, 0.4);
}

.nav-menu .admin-btn:hover {
  box-shadow: 0 4px 20px rgba(218, 165, 32, 0.4);
}

.nav-menu .dashboard-btn::after,
.nav-menu .admin-btn::after {
  display: none;
}

/* Hide mobile-specific elements on desktop */
.mobile-join-section,
.mobile-divider {
  display: none;
}

/* Show desktop join button only on desktop */
.desktop-join-section {
  display: inline-block;
  margin-left: auto;
}

/* Smooth transitions for all interactive elements */
.nav-menu * {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Add visual polish to navigation */
.nav-menu li {
  position: relative;
}

/* Add subtle divider before login section on desktop */
@media (min-width: 769px) {
  .nav-menu li:nth-last-child(2) {
    margin-left: 0.5rem;
    padding-left: 1rem;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
  }
}

.nav-toggle {
  display: none;
  flex-direction: column;
  cursor: pointer;
}

.nav-toggle span {
  width: 25px;
  height: 3px;
  background: var(--text-dark);
  margin: 3px 0;
  transition: 0.3s;
}

.main-content {
  flex: 1;
  padding: 3rem 0;
}

.hero {
  text-align: center;
  padding: 4rem 0;
  background: radial-gradient(circle at center, rgba(45, 80, 22, 0.1), rgba(135, 169, 107, 0.08));
}

.hero h1 {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

.hero p {
  font-size: 1.25rem;
  color: var(--text-medium);
  max-width: 600px;
  margin: 0 auto 2rem;
}

.btn-primary,
.btn-secondary {
  display: inline-block;
  padding: 0.75rem 2rem;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  font-size: 16px; /* Prevent iOS zoom */
  min-height: 44px; /* iOS touch target */
  -webkit-appearance: none; /* Remove iOS default styling */
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--gradient-earth);
  color: white;
  box-shadow: 0 4px 15px rgba(45, 80, 22, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(45, 80, 22, 0.5);
}

.btn-secondary {
  background: transparent;
  color: var(--text-dark);
  border: 2px solid var(--deep-purple);
}

.btn-secondary:hover {
  background: var(--deep-purple);
  color: white;
  border-color: var(--deep-purple);
}

.card {
  background: var(--paper-cream);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(45, 80, 22, 0.15);
  position: relative;
}

.card:hover {
  transform: translateY(-3px) rotate(0.5deg);
  box-shadow: 0 12px 30px rgba(45, 80, 22, 0.25);
  border-color: var(--sage-green);
}

.card::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: var(--gradient-mystical);
  border-radius: 17px;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover::before {
  opacity: 0.1;
}

.rock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.rock-card {
  position: relative;
  overflow: hidden;
}

.rock-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 10px;
}

.rock-card h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1.25rem;
}

.rock-card p {
  color: var(--text-medium);
  font-size: 1rem; /* 16px - iOS minimum */
}

.rock-card .rock-stats {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.rock-card .stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-medium);
  font-size: 1rem; /* 16px - iOS minimum */
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--charcoal-dark);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 1rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--charcoal-dark);
  font-size: 16px; /* Prevent iOS zoom */
  transition: all 0.3s ease;
  min-height: 44px; /* iOS touch target */
  -webkit-appearance: none; /* Remove iOS default styling */
  -webkit-tap-highlight-color: transparent;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--sage-green);
  box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.2);
}

.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.upload-area:hover {
  border-color: var(--accent-orange);
  background: rgba(135, 169, 107, 0.08);
}

.upload-area.dragover {
  border-color: var(--accent-pink);
  background: rgba(236, 72, 153, 0.05);
}

.map-container {
  height: 500px;
  border-radius: 15px;
  overflow: hidden;
  margin: 2rem 0;
  box-shadow: var(--shadow);
}

.leaderboard {
  background: var(--paper-cream);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--gold-accent);
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.leaderboard-item:hover {
  background: linear-gradient(90deg, rgba(45, 80, 22, 0.05), rgba(135, 169, 107, 0.08));
  padding-left: 1.5rem;
  border-radius: 8px;
}

.leaderboard-item:last-child {
  border-bottom: none;
}

.leaderboard-rank {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--gradient-earth);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  min-width: 40px;
}

.artist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.artist-card {
  text-align: center;
}

.artist-card .avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  border: 3px solid var(--accent-orange);
  object-fit: cover;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.stat-card {
  background: linear-gradient(135deg, rgba(72, 61, 139, 0.1), rgba(135, 169, 107, 0.1));
  padding: 1.5rem;
  border-radius: 15px;
  text-align: center;
  border: 1px solid rgba(45, 80, 22, 0.15);
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(45, 80, 22, 0.15);
}

.stat-card .stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--gradient-earth);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .stat-label {
  color: var(--text-medium);
  margin-top: 0.5rem;
}

.footer {
  background: var(--charcoal-dark);
  color: var(--canvas-white);
  border-top: 3px solid var(--gold-accent);
  padding: 3rem 0 1rem;
  margin-top: auto;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-section h3,
.footer-section h4 {
  margin-bottom: 1rem;
}

.footer-section ul {
  list-style: none;
}

.footer-section ul li {
  margin-bottom: 0.5rem;
}

.footer-section a {
  color: var(--canvas-white);
  text-decoration: none;
  transition: color 0.3s ease;
  opacity: 0.8;
}

.footer-section a:hover {
  color: var(--gold-accent);
  opacity: 1;
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid rgba(218, 165, 32, 0.3);
  color: var(--canvas-white);
  opacity: 0.7;
}

.footer-bottom a {
  color: var(--canvas-white);
  text-decoration: none;
  opacity: 0.9;
  transition: color 0.3s ease;
}

.footer-bottom a:hover {
  color: var(--gold-accent);
  opacity: 1;
  text-decoration: underline;
}

.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.alert-error {
  background: rgba(239, 68, 68, 0.95);
  border: 1px solid rgba(239, 68, 68, 1);
  color: white;
}

.alert-success {
  background: rgba(16, 185, 129, 0.95);
  border: 1px solid rgba(16, 185, 129, 1);
  color: white;
}

/* iOS Active State Improvements */
@media (hover: none) and (pointer: coarse) {
  /* Touch device optimizations - removed scaling to prevent shape change on Enter key */
  .btn-primary:active,
  .btn-secondary:active {
    /* Removed transform: scale(0.98) to prevent button shape change on form submission */
    transition: transform 0.1s ease;
  }

  .card:active {
    transform: scale(0.99);
  }

  /* Remove hover effects on touch devices */
  .card:hover {
    transform: none;
    box-shadow: 0 4px 10px rgba(45, 80, 22, 0.15);
  }

  .rock-card:hover {
    transform: none;
  }

  /* Faster touch feedback */
  * {
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }

  /* Better scrolling */
  .rock-grid,
  .artist-grid,
  .stories-grid {
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .rock-card,
  .artist-card,
  .story-card {
    scroll-snap-align: start;
  }
}

@media (max-width: 768px) {
  .nav-menu {
    display: none !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(254, 254, 254, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-direction: column;
    padding: 1.5rem 1rem;
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
    box-shadow: 0 8px 32px rgba(45, 80, 22, 0.15);
    border-top: 2px solid var(--sage-green);
    z-index: 9999;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    /* iOS scroll improvements */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border-radius: 0 0 20px 20px;
    /* Force hardware acceleration */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
  }

  .nav-menu.active {
    display: flex !important;
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
  }

  .nav-menu li {
    width: 100%;
    text-align: center;
    padding: 0.25rem 0;
  }

  /* Mobile menu section dividers */
  .mobile-divider {
    display: block !important;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 0.75rem 0;
    padding: 0 !important;
  }

  /* Special styling for join section */
  .mobile-join-section {
    display: block !important;
    padding: 0.75rem 0 !important;
  }

  .mobile-join-section .join-btn {
    background: var(--gradient-earth);
    box-shadow: 0 4px 20px rgba(45, 80, 22, 0.4);
    font-size: 1.1rem;
    padding: 1.25rem 2rem;
    border-radius: 30px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
  }

  .mobile-join-section .join-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
  }

  .mobile-join-section .join-btn:hover:before {
    left: 100%;
  }

  /* Hide desktop-specific elements on mobile */
  .desktop-join-section {
    display: none !important;
  }

  .nav-menu a {
    display: flex;
    padding: 1rem 1.5rem;
    width: 100%;
    min-height: 44px; /* iOS touch target */
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 1rem;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    text-decoration: none;
    margin: 0.25rem 0;
  }

  .nav-menu a:hover,
  .nav-menu a:active {
    background: rgba(135, 169, 107, 0.1);
    color: var(--sage-green);
    transform: translateX(5px);
  }

  /* Mobile styling for primary buttons (Join, Dashboard, Admin) */
  .nav-menu .btn-primary {
    width: 90%;
    margin: 0.5rem auto;
    display: flex !important;
    background: var(--gradient-earth);
    color: white !important;
    border-radius: 25px;
    font-weight: 600;
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 15px rgba(45, 80, 22, 0.3);
    justify-content: center;
    align-items: center;
    min-height: 44px;
  }

  .nav-menu .btn-primary:hover {
    background: var(--gradient-earth);
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(45, 80, 22, 0.4);
  }

  /* Specific styling for Dashboard and Admin buttons */
  .nav-menu .dashboard-btn,
  .nav-menu .admin-btn {
    width: 90%;
    margin: 0.5rem auto;
    display: flex;
  }

  .nav-toggle {
    display: flex;
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(135, 169, 107, 0.3);
  }

  .nav-toggle:hover,
  .nav-toggle:active {
    background: rgba(135, 169, 107, 0.1);
    transform: scale(1.05);
  }

  .nav-toggle span {
    width: 22px;
    height: 2px;
    background: var(--sage-green);
    margin: 2px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
  }

  /* Animate hamburger to X */
  .nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .nav-toggle.active span:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
  }

  .hero h1 {
    font-size: 2.5rem;
  }

  .rock-grid,
  .artist-grid {
    grid-template-columns: 1fr;
  }

  .footer-content {
    grid-template-columns: 1fr;
  }

  /* Prevent horizontal scroll on mobile */
  html,
  body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
  }

  /* Fix container overflow */
  .container {
    overflow-x: hidden;
    max-width: 100%;
  }

  /* Fix form elements on mobile */
  input[type='text'],
  input[type='email'],
  input[type='password'],
  input[type='tel'],
  input[type='number'],
  input[type='search'],
  input[type='url'],
  textarea,
  select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Better touch targets */
  button,
  .btn-primary,
  .btn-secondary {
    min-height: 44px;
  }
}

/* Component-specific iOS fixes not covered in theme.css */
@supports (-webkit-touch-callout: none) {
  /* Fix select dropdown on iOS */
  select {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="6"><path d="M0 0l6 6 6-6z" fill="%23333"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
  }

  /* Fix sticky elements */
  .navbar {
    position: -webkit-sticky;
    position: sticky;
  }

  /* Fix fixed positioning */
  .nav-menu.active {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* iOS Modal and Overlay Fixes */
.modal,
.overlay,
.popup {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* iOS Touch and Interaction Improvements */
a,
button,
input,
textarea,
select,
.clickable,
[role='button'] {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
}

/* Allow text selection for inputs */
input[type='text'],
input[type='email'],
input[type='password'],
input[type='search'],
input[type='tel'],
input[type='url'],
textarea {
  -webkit-user-select: text;
  user-select: text;
}

/* Text should be selectable */
p,
span,
h1,
h2,
h3,
h4,
h5,
h6,
.text-content {
  -webkit-user-select: text;
  user-select: text;
}

/* iOS File Input Fix */
input[type='file'] {
  width: 100%;
  font-size: 16px;
}

/* iOS-specific fixes when class is added by JavaScript */
.ios-device input[type='submit'],
.ios-device button {
  -webkit-appearance: none;
  appearance: none;
}

.ios-device .nav-menu {
  /* Fix for iOS Safari menu rendering */
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  /* Better iOS backdrop blur */
  -webkit-backdrop-filter: blur(20px);
}

.ios-device .btn-primary,
.ios-device .btn-secondary {
  /* Ensure buttons are clickable on iOS */
  position: relative;
  z-index: 1;
}

/* iOS-specific mobile menu improvements */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 768px) {
    .nav-menu {
      /* Improve iOS Safari rendering */
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
      will-change: transform;
      -webkit-backdrop-filter: blur(20px);
      backdrop-filter: blur(20px);
    }

    .nav-menu.active {
      /* Prevent iOS bounce scrolling */
      position: fixed;
      top: 100%;
      left: 0;
      right: 0;
      bottom: 0;
      max-height: calc(100vh - 80px);
      -webkit-overflow-scrolling: touch;
    }

    .nav-toggle {
      /* Better iOS touch handling */
      -webkit-user-select: none;
      user-select: none;
    }

    .nav-menu a,
    .nav-menu .btn-primary {
      /* Improve iOS touch targets */
      -webkit-tap-highlight-color: rgba(135, 169, 107, 0.2);
      -webkit-touch-callout: none;
    }
  }
}

/* Fix iOS rubber band scrolling */
.ios-device body {
  position: fixed;
  width: 100%;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Upload area specific for iOS */
.upload-area {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

/* iOS Landscape Mode Adjustments */
@media screen and (max-width: 812px) and (orientation: landscape) {
  .navbar {
    padding: 0.5rem 0;
  }

  .hero-section {
    padding: 2rem 0;
  }

  .hero-title {
    font-size: 2rem;
  }

  .main-content {
    padding: 2rem 0;
  }
}

/* iOS Notch Support (iPhone X and later) */
@supports (padding: max(0px)) {
  .navbar {
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  .footer {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  /* Modal content with safe areas */
  .modal-content,
  .popup-content {
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
      max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  }
}

/* Mobile Text Overflow Fixes */
@media (max-width: 768px) {
  /* Fix button text overflow on mobile */
  .btn-primary,
  .btn-secondary,
  .btn-small {
    width: 100%;
    padding: 1rem;
    font-size: 16px;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    min-height: 44px;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  /* Step bubbles and info cards */
  .step-bubble,
  .info-bubble,
  .text-bubble {
    padding: 0.75rem;
    font-size: 16px;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.3;
    overflow-wrap: break-word;
  }

  /* Camera and gallery buttons */
  .camera-btn,
  .gallery-btn {
    padding: 0.75rem 1rem;
    font-size: 16px;
    white-space: normal;
    word-wrap: break-word;
    min-height: 44px;
    width: 48%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
  }

  .camera-btn span,
  .gallery-btn span {
    font-size: 16px;
    line-height: 1;
  }

  /* Card content */
  .card h3,
  .rock-card h3 {
    font-size: 1.1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .card p,
  .rock-card p {
    font-size: 1rem; /* 16px - iOS minimum */
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Navigation menu items */
  .nav-menu a {
    font-size: 16px;
    word-wrap: break-word;
  }

  /* Form labels and inputs */
  .form-group label {
    font-size: 16px;
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    font-size: 16px; /* Prevent iOS zoom */
  }

  /* Dashboard and admin buttons in navbar */
  .nav-menu .dashboard-btn,
  .nav-menu .admin-btn {
    font-size: 16px;
    padding: 0.75rem 1.25rem;
    white-space: normal;
    word-wrap: break-word;
  }

  /* Alert messages */
  .alert {
    font-size: 16px;
    padding: 0.75rem;
    word-wrap: break-word;
  }

  /* Hero text */
  .hero p {
    font-size: 1rem;
    padding: 0 1rem;
    word-wrap: break-word;
  }

  /* Stat cards */
  .stat-card .stat-value {
    font-size: 2rem;
  }

  .stat-card .stat-label {
    font-size: 1rem; /* 16px - iOS minimum */
  }
}

/* Small Mobile Devices (iPhone SE, older phones) */
@media (max-width: 375px) {
  .container {
    padding: 0 15px;
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
  }

  .hero h1 {
    font-size: 2rem;
    line-height: 1.2;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .btn-primary,
  .btn-secondary {
    font-size: 14px;
    padding: 12px 20px;
    min-height: 44px;
  }

  .rock-card {
    min-height: 200px;
  }

  .rock-card h3 {
    font-size: 1.1rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    font-size: 16px;
    padding: 12px;
  }

  .navbar .container {
    padding: 0.5rem 1rem;
  }

  .nav-brand a {
    font-size: 1.1rem;
  }

  .footer {
    padding: 1.5rem 0;
  }

  .footer-section h3,
  .footer-section h4 {
    font-size: 1.1rem;
  }

  /* Ensure modals fit on small screens */
  .modal-content {
    margin: 10px;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
  }

  /* Fix for small screen file upload areas */
  .upload-area,
  .artist-upload-area {
    padding: 1rem;
  }

  .camera-options {
    flex-direction: column;
    gap: 0.5rem;
  }

  .camera-btn,
  .gallery-btn {
    width: 100%;
    padding: 1rem;
  }
}

/* Very Small Devices (older phones, 360px width) */
@media (max-width: 360px) {
  .hero h1 {
    font-size: 1.75rem;
  }

  .hero-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .hero-actions .btn-primary,
  .hero-actions .btn-secondary {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .step-card {
    padding: 1rem;
  }

  .rock-grid {
    grid-template-columns: 1fr;
  }

  /* Ensure form elements are usable */
  .auth-container {
    padding: 1rem;
  }

  .form-group label {
    font-size: 14px;
  }
}

/* iOS Performance Optimizations */
@supports (-webkit-touch-callout: none) {
  /* Smooth scrolling for iOS */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Better scrolling performance */
  .main-content {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
  
  /* Fix for iOS scrolling issues with fixed elements */
  .navbar {
    position: -webkit-sticky;
    position: sticky;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
  }
  
  /* Optimize touch response */
  a, button, input, textarea, select, .btn-primary, .btn-secondary, .rock-card {
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
  }
  
  /* Prevent text selection on buttons */
  button, .btn-primary, .btn-secondary {
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* Fix iOS bounce scrolling at edges */
  body {
    overscroll-behavior: none;
  }
  
  /* Ensure forms don't zoom on iOS */
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* iOS-specific text fixes */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 768px) {
    /* Ensure all interactive elements have proper text wrapping */
    button,
    .btn-primary,
    .btn-secondary,
    .dashboard-btn,
    .admin-btn,
    .camera-btn,
    .gallery-btn {
      -webkit-line-clamp: 2;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 100%;
    }

    /* Fix text in small containers */
    .step-bubble,
    .info-bubble,
    .text-bubble {
      max-width: 100%;
      box-sizing: border-box;
    }
  }
}

/* Journey Map Markers - More Clearly Defined */
.journey-marker {
  background: var(--gradient-earth);
  border-radius: 50%;
  border: 3px solid white;
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.3),
    0 0 0 2px var(--sage-green),
    0 0 25px rgba(135, 169, 107, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px !important;
  height: 40px !important;
  font-weight: bold;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  z-index: 1000;
}

.journey-marker::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid var(--sage-green);
  z-index: -1;
}

.journey-marker::after {
  content: '';
  position: absolute;
  width: 60px;
  height: 60px;
  border: 2px solid var(--sage-green);
  border-radius: 50%;
  animation: pulse-ring 2s ease-out infinite;
  opacity: 0.5;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.8);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

.marker-number {
  color: white;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.journey-marker:hover {
  transform: scale(1.1);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    0 0 0 3px var(--sage-green),
    0 0 35px rgba(135, 169, 107, 0.6);
}

/* Start and End markers - Special styling */
.journey-marker-start {
  background: linear-gradient(135deg, #4caf50, #45a049);
  box-shadow:
    0 4px 15px rgba(76, 175, 80, 0.4),
    0 0 0 2px #4caf50,
    0 0 30px rgba(76, 175, 80, 0.5);
}

.journey-marker-start::before {
  border-top-color: #4caf50;
}

.journey-marker-end {
  background: linear-gradient(135deg, #ff5722, #e64a19);
  box-shadow:
    0 4px 15px rgba(255, 87, 34, 0.4),
    0 0 0 2px #ff5722,
    0 0 30px rgba(255, 87, 34, 0.5);
}

.journey-marker-end::before {
  border-top-color: #ff5722;
}

/* Journey path line styling */
.leaflet-overlay-pane path {
  stroke: var(--sage-green);
  stroke-width: 3;
  stroke-opacity: 0.8;
  stroke-dasharray: 10, 5;
  animation: dash 20s linear infinite;
}

@keyframes dash {
  to {
    stroke-dashoffset: -100;
  }
}
