/* ===============================================
   QUANTUM STOPWATCH - EXTRAORDINARY VISUAL EFFECTS
   =============================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Base Colors */
  --bg-primary: #0a0a0a;
  --bg-secondary: #1a1a1a;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  
  /* Neon Colors */
  --neon-blue: #00f5ff;
  --neon-purple: #8b5cf6;
  --neon-green: #10ff10;
  --neon-orange: #ff6b35;
  --neon-pink: #ff10f0;
  --neon-yellow: #ffff00;
  
  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-accent: var(--neon-blue);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
  --gradient-success: linear-gradient(135deg, #10ff10, #00ff88);
  --gradient-warning: linear-gradient(135deg, #ffff00, #ff6b35);
  --gradient-danger: linear-gradient(135deg, #ff10f0, #ff6b35);
  --gradient-info: linear-gradient(135deg, #00f5ff, #8b5cf6);
  
  /* Shadows */
  --shadow-neon: 0 0 20px rgba(0, 245, 255, 0.5);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.3);
  --shadow-deep: 0 20px 40px rgba(0, 0, 0, 0.8);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(0, 0, 0, 0.1);
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --shadow-deep: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* ===============================================
   ANIMATED BACKGROUND SYSTEM
   =============================================== */

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.animated-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  overflow: hidden;
}

.bg-layer {
  position: absolute;
  width: 200%;
  height: 200%;
  opacity: 0.1;
  animation: float 20s ease-in-out infinite;
}

.layer-1 {
  background: radial-gradient(circle at 20% 50%, var(--neon-blue) 0%, transparent 50%);
  animation-delay: 0s;
  animation-duration: 25s;
}

.layer-2 {
  background: radial-gradient(circle at 80% 20%, var(--neon-purple) 0%, transparent 50%);
  animation-delay: -8s;
  animation-duration: 30s;
}

.layer-3 {
  background: radial-gradient(circle at 40% 80%, var(--neon-pink) 0%, transparent 50%);
  animation-delay: -16s;
  animation-duration: 35s;
}

@keyframes float {
  0%, 100% { transform: translate(-10%, -10%) rotate(0deg); }
  25% { transform: translate(-5%, -15%) rotate(90deg); }
  50% { transform: translate(-15%, -5%) rotate(180deg); }
  75% { transform: translate(-5%, -10%) rotate(270deg); }
}

/* ===============================================
   PARTICLE SYSTEM CANVAS
   =============================================== */

.particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* ===============================================
   MAIN CONTAINER WITH GLASSMORPHISM
   =============================================== */

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-height: 100vh;
  box-sizing: border-box;
}

.container {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 30px;
  padding: 40px;
  box-shadow: var(--shadow-deep);
  text-align: center;
  max-width: 600px;
  width: calc(100% - 40px);
  margin: 20px auto;
  position: relative;
  overflow: hidden;
  animation: containerGlow 4s ease-in-out infinite alternate;
  transition: all 0.3s ease;
}

@keyframes containerGlow {
  0% { box-shadow: var(--shadow-deep), 0 0 30px rgba(0, 245, 255, 0.1); }
  100% { box-shadow: var(--shadow-deep), 0 0 50px rgba(139, 92, 246, 0.2); }
}

.container::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: var(--gradient-primary);
  border-radius: 32px;
  z-index: -1;
  opacity: 0.1;
  animation: borderGlow 3s ease-in-out infinite alternate;
}

@keyframes borderGlow {
  0% { opacity: 0.1; }
  100% { opacity: 0.3; }
}

/* ===============================================
   ENHANCED HEADER DESIGN
   =============================================== */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  position: relative;
}

.title-container {
  position: relative;
}

.title {
  font-family: 'Orbitron', monospace;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
}

.title-main {
  font-size: 2.5rem;
  font-weight: 900;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 30px rgba(0, 245, 255, 0.5);
  animation: titlePulse 2s ease-in-out infinite alternate;
}

.title-sub {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.5em;
  margin-top: -5px;
  text-transform: uppercase;
}

@keyframes titlePulse {
  0% { filter: brightness(1) drop-shadow(0 0 10px rgba(0, 245, 255, 0.3)); }
  100% { filter: brightness(1.2) drop-shadow(0 0 20px rgba(0, 245, 255, 0.6)); }
}

.title-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle, rgba(0, 245, 255, 0.1) 0%, transparent 70%);
  animation: glowPulse 3s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes glowPulse {
  0% { opacity: 0.3; transform: scale(1); }
  100% { opacity: 0.6; transform: scale(1.1); }
}

.header-controls {
  display: flex;
  gap: 15px;
}

.theme-toggle,
.sound-toggle {
  position: relative;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.theme-toggle:hover,
.sound-toggle:hover {
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 15px 40px rgba(0, 245, 255, 0.4);
}

.toggle-icon {
  font-size: 1.5rem;
  transition: all 0.3s ease;
  z-index: 2;
}

.toggle-ripple {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, var(--neon-blue) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: all 0.6s ease;
}

.theme-toggle:active .toggle-ripple,
.sound-toggle:active .toggle-ripple {
  opacity: 0.3;
  transform: scale(1);
}

/* ===============================================
   EXTRAORDINARY DISPLAY WITH VISUAL EFFECTS
   =============================================== */

.display-container {
  position: relative;
  margin: 40px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.display-bg-effects {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 350px;
  height: 350px;
  pointer-events: none;
}

.hologram-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 245, 255, 0.03) 2px,
      rgba(0, 245, 255, 0.03) 4px
    );
  animation: hologramScan 2s linear infinite;
}

@keyframes hologramScan {
  0% { transform: translateY(0); }
  100% { transform: translateY(20px); }
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--neon-blue), transparent);
  animation: scanMove 3s ease-in-out infinite;
  box-shadow: 0 0 10px var(--neon-blue);
}

@keyframes scanMove {
  0%, 100% { transform: translateY(0) scaleX(0); }
  50% { transform: translateY(300px) scaleX(1); }
}

.energy-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 320px;
  height: 320px;
  border: 2px solid transparent;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: conic-gradient(var(--neon-blue), var(--neon-purple), var(--neon-pink), var(--neon-blue));
  mask: radial-gradient(circle, transparent 158px, black 160px);
  -webkit-mask: radial-gradient(circle, transparent 158px, black 160px);
  animation: energyRotate 4s linear infinite;
  opacity: 0.6;
}

@keyframes energyRotate {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.display {
  font-family: 'Orbitron', monospace;
  font-size: 4.5rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 40px rgba(0, 245, 255, 0.8);
  letter-spacing: 0.1em;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 20px rgba(0, 245, 255, 0.6));
  transition: all 0.3s ease;
}

.display-overlay {
  position: absolute;
  bottom: -30px;
  right: 20px;
  z-index: 3;
}

.milliseconds {
  font-family: 'Orbitron', monospace;
  font-size: 1.2rem;
  color: var(--text-secondary);
  opacity: 0.8;
}

.progress-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.progress-circle {
  transform: rotate(-90deg);
}

.progress-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 3;
}

.progress-fill {
  fill: none;
  stroke: url(#progressGradient);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 879.6;
  stroke-dashoffset: 879.6;
  transition: stroke-dashoffset 0.3s ease;
  filter: drop-shadow(0 0 8px rgba(0, 245, 255, 0.6));
}

/* ===============================================
   3D ENHANCED CONTROL BUTTONS
   =============================================== */

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 20px;
  margin: 40px 0;
  perspective: 1000px;
}

.btn {
  position: relative;
  height: 70px;
  border: none;
  border-radius: 35px;
  background: var(--glass-bg);
  backdrop-filter: blur(15px);
  cursor: pointer;
  overflow: hidden;
  transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1); /* Faster transition for responsiveness */
  transform-style: preserve-3d;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  
  /* Improve touch and mouse responsiveness */
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  transform: translateY(-8px) rotateX(10deg);
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.4),
    0 0 30px var(--neon-blue);
  transition: all 0.05s ease; /* Ultra-fast hover response */
}

/* Add active state for immediate feedback */
.btn:active {
  transform: translateY(-2px) rotateX(5deg);
  transition: all 0.05s ease;
}

.btn:active {
  transform: translateY(-2px) rotateX(5deg) scale(0.98);
}

.btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  z-index: 2;
  height: 100%;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: none;
}

.btn-icon {
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

.btn-text {
  font-size: 0.9rem;
}

.btn:hover .btn-icon {
  transform: scale(1.2) rotate(5deg);
}

.btn-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 35px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
  pointer-events: none;
}

.btn:hover .btn-glow {
  opacity: 1;
}

.btn-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 35px;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.btn-particles::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(transparent, rgba(255, 255, 255, 0.1), transparent);
  animation: particleRotate 3s linear infinite;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn:hover .btn-particles::before {
  opacity: 1;
}

@keyframes particleRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Button Specific Styles */
.btn-start {
  background: linear-gradient(135deg, rgba(16, 255, 16, 0.2), rgba(0, 255, 136, 0.2));
  color: var(--neon-green);
  border: 1px solid rgba(16, 255, 16, 0.3);
}

.btn-start .btn-glow {
  background: var(--gradient-success);
  opacity: 0.1;
}

.btn-pause:not(:disabled) {
  background: linear-gradient(135deg, rgba(255, 255, 0, 0.2), rgba(255, 107, 53, 0.2));
  color: var(--neon-yellow);
  border: 1px solid rgba(255, 255, 0, 0.3);
}

.btn-pause:not(:disabled):hover {
  background: linear-gradient(135deg, rgba(255, 255, 0, 0.3), rgba(255, 107, 53, 0.3));
  box-shadow: 0 0 20px rgba(255, 255, 0, 0.4);
  transform: translateY(-2px);
}

.btn-pause .btn-glow {
  background: var(--gradient-warning);
  opacity: 0.1;
}

.btn-reset {
  background: linear-gradient(135deg, rgba(255, 16, 240, 0.2), rgba(255, 107, 53, 0.2));
  color: var(--neon-pink);
  border: 1px solid rgba(255, 16, 240, 0.3);
}

.btn-reset .btn-glow {
  background: var(--gradient-danger);
  opacity: 0.1;
}

.btn-lap {
  background: linear-gradient(135deg, rgba(0, 245, 255, 0.2), rgba(139, 92, 246, 0.2));
  color: var(--neon-blue);
  border: 1px solid rgba(0, 245, 255, 0.3);
}

.btn-lap .btn-glow {
  background: var(--gradient-info);
  opacity: 0.1;
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.8);
  pointer-events: none;
}

.btn:not(:disabled) {
  pointer-events: auto;
  cursor: pointer;
  /* Extend interaction area for better responsiveness */
  position: relative;
}

.btn:not(:disabled)::before {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  pointer-events: auto;
  z-index: -1;
}

.btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  /* Faster transition for better responsiveness */
  transition: all 0.1s ease;
}

.btn:disabled * {
  pointer-events: none;
}

.btn:disabled:hover {
  transform: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ===============================================
   STATISTICS PANEL
   =============================================== */

.stats-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 30px 0;
  padding: 25px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.stats-item {
  text-align: center;
  padding: 15px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stats-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 245, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

.stats-item:hover::before {
  left: 100%;
}

.stats-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 245, 255, 0.2);
}

.stats-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.stats-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-accent);
  text-shadow: 0 0 10px rgba(0, 245, 255, 0.3);
}

/* ===============================================
   ENHANCED LAPS SECTION
   =============================================== */

.laps-section {
  margin-top: 40px;
}

.laps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding: 0 10px;
}

.laps-title {
  font-family: 'Orbitron', monospace;
  font-size: 1.3rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.laps-icon {
  font-size: 1.5rem;
  animation: iconPulse 2s ease-in-out infinite alternate;
}

@keyframes iconPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.1); }
}

.laps-controls {
  display: flex;
  gap: 10px;
}

.export-laps,
.clear-laps {
  padding: 10px 15px;
  border: none;
  border-radius: 15px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.export-laps:hover,
.clear-laps:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 245, 255, 0.3);
  background: rgba(0, 245, 255, 0.1);
}

.laps-list {
  max-height: 400px;
  overflow-y: auto;
  background: var(--glass-bg);
  backdrop-filter: blur(15px);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.lap-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  animation: lapSlideIn 0.5s ease-out;
}

@keyframes lapSlideIn {
  0% {
    opacity: 0;
    transform: translateX(-30px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

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

.lap-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--gradient-primary);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.lap-item:hover::before {
  transform: scaleY(1);
}

.lap-item:hover {
  background: rgba(0, 245, 255, 0.05);
  transform: translateX(10px);
  box-shadow: 0 5px 20px rgba(0, 245, 255, 0.1);
}

.lap-number {
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lap-time {
  font-family: 'Orbitron', monospace;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.empty-laps {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 15px;
  animation: emptyPulse 2s ease-in-out infinite alternate;
}

@keyframes emptyPulse {
  0% { opacity: 0.5; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.1); }
}

.empty-text {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-subtext {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* ===============================================
   RUNNING STATE ANIMATIONS
   =============================================== */

.running .display {
  animation: displayPulse 1s ease-in-out infinite alternate;
}

@keyframes displayPulse {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 20px rgba(0, 245, 255, 0.6));
  }
  100% {
    transform: scale(1.02);
    filter: drop-shadow(0 0 40px rgba(0, 245, 255, 0.9));
  }
}

.running .energy-ring {
  animation-duration: 1s;
  opacity: 1;
}

.running .container {
  box-shadow: 
    var(--shadow-deep),
    0 0 60px rgba(16, 255, 16, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ===============================================
   CUSTOM SCROLLBAR
   =============================================== */

.laps-list::-webkit-scrollbar {
  width: 8px;
}

.laps-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.laps-list::-webkit-scrollbar-thumb {
  background: var(--gradient-primary);
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 245, 255, 0.3);
}

.laps-list::-webkit-scrollbar-thumb:hover {
  background: var(--gradient-info);
  box-shadow: 0 0 20px rgba(0, 245, 255, 0.5);
}

/* Mobile scrollbar */
@media (max-width: 768px) {
  .laps-list::-webkit-scrollbar {
    width: 6px;
  }
  
  .laps-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 245, 255, 0.5) rgba(255, 255, 255, 0.05);
  }
}

/* ===============================================
   RESPONSIVE DESIGN
   =============================================== */

/* ===============================================
   PERFORMANCE OPTIMIZATIONS
   =============================================== */

/* Reduce animations for better performance */
@media (max-width: 768px), (max-height: 600px) {
  /* Disable heavy background animations on mobile */
  .bg-layer {
    animation-duration: 60s; /* Slow down from 20s */
  }
  
  /* Reduce container glow frequency */
  .container {
    animation-duration: 8s; /* Slow down from 4s */
  }
  
  /* Disable some heavy effects on mobile */
  .hologram-lines,
  .energy-ring {
    display: none;
  }
  
  /* Simplify scan line */
  .scan-line {
    animation-duration: 6s; /* Slow down from 3s */
  }
  
  /* Reduce button particle effects */
  .btn-particles::before {
    animation-duration: 6s; /* Slow down from 3s */
  }
}

/* Performance mode for low-end devices */
@media (max-width: 480px) {
  /* Disable most animations */
  .bg-layer {
    animation: none;
    opacity: 0.3;
  }
  
  .container {
    animation: none;
    box-shadow: var(--shadow-deep);
    /* Disable backdrop filter on low-end devices */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255, 255, 255, 0.1);
  }
  
  .title-glow {
    animation: none;
    opacity: 0.5;
  }
  
  .display-bg-effects {
    display: none;
  }
  
  .btn-particles {
    display: none;
  }
  
  /* Keep only essential visual effects */
  .btn-glow {
    transition: opacity 0.2s ease;
  }
}

/* ===============================================
   COMPREHENSIVE RESPONSIVE DESIGN
   =============================================== */

/* Base mobile-first approach */
@media (max-width: 1200px) {
  .container {
    max-width: 900px;
    padding: 40px 30px;
  }
  
  .display {
    font-size: 4rem;
  }
  
  .progress-circle {
    width: 280px;
    height: 280px;
  }
}

/* Large tablets and small desktops */
@media (max-width: 992px) {
  .container {
    max-width: 750px;
    padding: 35px 25px;
    margin: 15px;
  }
  
  .header {
    gap: 20px;
  }
  
  .title-main {
    font-size: 2.5rem;
  }
  
  .title-sub {
    font-size: 1rem;
  }
  
  .display {
    font-size: 3.5rem;
  }
  
  .display-container {
    margin: 30px 0;
  }
  
  .progress-circle {
    width: 250px;
    height: 250px;
  }
  
  .controls {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 30px 0;
  }
  
  .btn {
    height: 65px;
    font-size: 0.9rem;
  }
  
  .stats-panel {
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 25px 20px;
  }
  
  .stats-value {
    font-size: 1.1rem;
  }
}

/* Standard tablets */
@media (max-width: 768px) {
  .container {
    padding: 30px 20px;
    margin: 10px;
    min-height: auto;
  }

  /* Header adjustments */
  .header {
    flex-direction: column;
    gap: 20px;
    text-align: center;
  }
  
  .header-controls {
    justify-content: center;
  }
  
  .title-main {
    font-size: 2.2rem;
  }
  
  .title-sub {
    font-size: 0.9rem;
  }

  /* Display adjustments */
  .display {
    font-size: 3rem;
  }
  
  .milliseconds {
    font-size: 1rem;
  }
  
  .display-container {
    margin: 25px 0;
  }
  
  .progress-circle {
    width: 220px;
    height: 220px;
  }

  /* Controls adjustments */
  .controls {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 25px 0;
  }
  
  .btn {
    height: 60px;
    padding: 0 20px;
  }
  
  .btn-text {
    font-size: 0.8rem;
  }
  
  .btn-icon {
    font-size: 1.1rem;
  }

  /* Stats panel adjustments */
  .stats-panel {
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 20px 15px;
  }
  
  .stats-item {
    text-align: center;
    padding: 15px;
  }
  
  .stats-value {
    font-size: 1rem;
  }

  /* Laps section adjustments */
  .laps-header {
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
  }

  .laps-controls {
    justify-content: center;
  }
  
  .lap-item {
    padding: 15px;
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  
  .lap-number {
    font-size: 0.9rem;
  }
  
  .lap-time {
    font-size: 1.1rem;
  }
  
  .lap-split {
    font-size: 0.8rem;
  }

  /* Mobile scrollbar */
  .laps-list::-webkit-scrollbar {
    width: 6px;
  }
  
  .laps-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 245, 255, 0.5) rgba(255, 255, 255, 0.05);
    max-height: 300px;
  }
}

/* Large phones */
@media (max-width: 576px) {
  .container {
    padding: 25px 15px;
    margin: 8px;
  }
  
  /* Header for phones */
  .title-main {
    font-size: 1.8rem;
  }
  
  .title-sub {
    font-size: 0.8rem;
  }
  
  .header-controls {
    gap: 15px;
  }
  
  .theme-toggle,
  .sound-toggle {
    width: 45px;
    height: 45px;
  }

  /* Display for phones */
  .display {
    font-size: 2.5rem;
    padding: 20px;
  }
  
  .milliseconds {
    font-size: 0.9rem;
  }
  
  .progress-circle {
    width: 180px;
    height: 180px;
  }

  /* Controls for phones */
  .controls {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 20px 0;
  }
  
  .btn {
    height: 55px;
    padding: 0 15px;
  }
  
  .btn-content {
    gap: 8px;
  }
  
  .btn-text {
    font-size: 0.75rem;
  }
  
  .btn-icon {
    font-size: 1rem;
  }

  /* Stats for phones */
  .stats-panel {
    padding: 15px 10px;
    gap: 10px;
  }
  
  .stats-item {
    padding: 12px;
  }
  
  .stats-label {
    font-size: 0.7rem;
  }
  
  .stats-value {
    font-size: 0.9rem;
  }

  /* Laps for phones */
  .laps-title {
    font-size: 1rem;
  }
  
  .lap-item {
    padding: 12px;
    gap: 8px;
  }
  
  .lap-time {
    font-size: 1rem;
  }
  
  .export-laps,
  .clear-laps {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
}

/* Small phones */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }
  
  .container {
    padding: 20px 12px;
    margin: 5px;
  }
  
  /* Ultra-compact header */
  .title-main {
    font-size: 1.6rem;
  }
  
  .title-sub {
    font-size: 0.7rem;
  }

  /* Ultra-compact display */
  .display {
    font-size: 2.2rem;
    padding: 15px;
  }
  
  .progress-circle {
    width: 160px;
    height: 160px;
  }
  
  .display-overlay {
    bottom: 15px;
    right: 15px;
  }

  /* Ultra-compact controls */
  .btn {
    height: 50px;
    padding: 0 12px;
  }
  
  .btn-text {
    font-size: 0.7rem;
  }

  /* Ultra-compact stats */
  .stats-panel {
    padding: 12px 8px;
  }
  
  .stats-item {
    padding: 10px;
  }
  
  .stats-label {
    font-size: 0.65rem;
  }
  
  .stats-value {
    font-size: 0.85rem;
  }

  /* Ultra-compact laps */
  .laps-list {
    max-height: 250px;
  }
  
  .lap-item {
    padding: 10px;
  }
  
  .empty-laps {
    padding: 30px 20px;
  }
  
  .empty-text {
    font-size: 0.9rem;
  }
  
  .empty-subtext {
    font-size: 0.7rem;
  }
}

/* Extra small devices */
@media (max-width: 360px) {
  .container {
    padding: 15px 10px;
    margin: 3px;
  }
  
  .title-main {
    font-size: 1.4rem;
  }
  
  .display {
    font-size: 2rem;
  }
  
  .progress-circle {
    width: 140px;
    height: 140px;
  }
  
  .btn {
    height: 45px;
  }
  
  .btn-text {
    font-size: 0.65rem;
  }
  
  .stats-panel {
    padding: 10px 5px;
  }
  
  .lap-item {
    padding: 8px;
  }
}

/* Landscape orientation optimizations */
@media (max-height: 600px) and (orientation: landscape) {
  .container {
    padding: 15px 20px;
  }
  
  .header {
    flex-direction: row;
    justify-content: space-between;
  }
  
  .display-container {
    margin: 15px 0;
  }
  
  .progress-circle {
    width: 150px;
    height: 150px;
  }
  
  .controls {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 15px 0;
  }
  
  .btn {
    height: 45px;
  }
  
  .stats-panel {
    grid-template-columns: repeat(3, 1fr);
    padding: 15px;
  }
  
  .laps-list {
    max-height: 200px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .display {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
  }
}

/* Print styles */
@media print {
  body {
    background: white;
    color: black;
  }
  
  .animated-bg,
  .particle-canvas,
  .btn-glow,
  .btn-particles {
    display: none;
  }
  
  .container {
    box-shadow: none;
    background: white;
    border: 1px solid #ccc;
  }
}

/* ===============================================
   RESPONSIVE UTILITIES & TOUCH IMPROVEMENTS
   =============================================== */

/* Improve button touch targets */
.btn,
.theme-toggle,
.sound-toggle,
.export-laps,
.clear-laps {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Improve text readability on small screens */
@media (max-width: 480px) {
  * {
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
  }
}

/* Focus improvements for accessibility */
.btn:focus,
.theme-toggle:focus,
.sound-toggle:focus {
  outline: 2px solid var(--neon-blue);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .animated-bg,
  .particle-canvas {
    display: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --glass-bg: rgba(0, 0, 0, 0.9);
    --glass-border: rgba(255, 255, 255, 0.5);
  }
  
  .container {
    border-width: 2px;
  }
  
  .btn {
    border-width: 2px;
  }
}

/* Safe area adjustments for notched devices */
@supports (padding: max(0px)) {
  body {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}

/* ===============================================
   SPECIAL EFFECTS & ANIMATIONS
   =============================================== */

@keyframes neonFlicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.neon-flicker {
  animation: neonFlicker 0.1s infinite alternate;
}

/* Gradient definitions for SVG */
.progress-circle {
  filter: drop-shadow(0 0 8px rgba(0, 245, 255, 0.6));
}

/* Add some extra visual flair */
.container::after {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  background: conic-gradient(
    var(--neon-blue), 
    var(--neon-purple), 
    var(--neon-pink), 
    var(--neon-blue)
  );
  border-radius: 31px;
  z-index: -1;
  opacity: 0;
  animation: borderRotate 6s linear infinite;
  transition: opacity 0.3s ease;
}

.running .container::after {
  opacity: 0.3;
}

@keyframes borderRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Performance optimizations */
.btn,
.lap-item,
.stats-item {
  will-change: transform;
}

.display,
.title-main {
  will-change: filter, transform;
}

/* ===============================================
   ENHANCED BUTTON STATES AND LIGHT MODE FIXES
   =============================================== */

/* Enhanced pause button when enabled */
.btn-pause:not(:disabled) {
  background: linear-gradient(135deg, rgba(255, 255, 0, 0.4), rgba(255, 107, 53, 0.4)) !important;
  border: 2px solid rgba(255, 255, 0, 0.7) !important;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(255, 255, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  opacity: 1 !important;
  filter: none !important;
}

.btn-pause:not(:disabled):hover {
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(255, 255, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  transform: translateY(-8px) rotateX(10deg) !important;
}

/* Enhanced lap button when enabled */
.btn-lap:not(:disabled) {
  background: linear-gradient(135deg, rgba(0, 245, 255, 0.4), rgba(139, 92, 246, 0.4)) !important;
  border: 2px solid rgba(0, 245, 255, 0.7) !important;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(0, 245, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  opacity: 1 !important;
  filter: none !important;
}

.btn-lap:not(:disabled):hover {
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(0, 245, 255, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  transform: translateY(-8px) rotateX(10deg) !important;
}

/* Light mode specific button enhancements */
[data-theme="light"] .btn-start {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.4), rgba(16, 185, 129, 0.4)) !important;
  color: #047857 !important;
  border: 2px solid rgba(5, 150, 105, 0.6) !important;
  text-shadow: 0 0 10px rgba(5, 150, 105, 0.3) !important;
}

[data-theme="light"] .btn-pause {
  background: linear-gradient(135deg, rgba(202, 138, 4, 0.4), rgba(234, 88, 12, 0.4)) !important;
  color: #92400e !important;
  border: 2px solid rgba(202, 138, 4, 0.6) !important;
  text-shadow: 0 0 10px rgba(202, 138, 4, 0.3) !important;
}

[data-theme="light"] .btn-pause:not(:disabled) {
  background: linear-gradient(135deg, rgba(202, 138, 4, 0.5), rgba(234, 88, 12, 0.5)) !important;
  border: 2px solid rgba(202, 138, 4, 0.8) !important;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 0 20px rgba(202, 138, 4, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}

[data-theme="light"] .btn-reset {
  background: linear-gradient(135deg, rgba(190, 24, 93, 0.4), rgba(234, 88, 12, 0.4)) !important;
  color: #be185d !important;
  border: 2px solid rgba(190, 24, 93, 0.6) !important;
  text-shadow: 0 0 10px rgba(190, 24, 93, 0.3) !important;
}

[data-theme="light"] .btn-lap {
  background: linear-gradient(135deg, rgba(0, 102, 204, 0.4), rgba(107, 70, 193, 0.4)) !important;
  color: #0066cc !important;
  border: 2px solid rgba(0, 102, 204, 0.6) !important;
  text-shadow: 0 0 10px rgba(0, 102, 204, 0.3) !important;
}

[data-theme="light"] .btn-lap:not(:disabled) {
  background: linear-gradient(135deg, rgba(0, 102, 204, 0.5), rgba(107, 70, 193, 0.5)) !important;
  border: 2px solid rgba(0, 102, 204, 0.8) !important;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 0 20px rgba(0, 102, 204, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}

/* Light mode disabled buttons */
[data-theme="light"] .btn:disabled {
  opacity: 0.5 !important;
  filter: grayscale(0.6) brightness(0.8) !important;
  background: rgba(0, 0, 0, 0.1) !important;
  color: #999 !important;
  border: 2px solid rgba(0, 0, 0, 0.2) !important;
  text-shadow: none !important;
}

/* Enhanced button visibility for all themes */
.btn:not(:disabled) {
  opacity: 1 !important;
  filter: none !important;
}

.btn:not(:disabled):hover {
  opacity: 1 !important;
  filter: brightness(1.1) !important;
}