:root {
  --primary-color: #66c0f4;
  --primary-dark: #4a9cd9;
  --secondary-color: #5c7e10;
  --accent-color: #ffc857;
  --background-color: #0a0a15;
  --background-secondary: #0f0f23;
  --surface-color: #1a1a2e;
  --surface-elevated: #212143;
  --card-color: #16213e;
  --card-hover: #1e2a4a;
  --text-primary: #ffffff;
  --text-secondary: #c7d5e0;
  --text-muted: #8f98a0;
  --text-accent: #66c0f4;
  --border-color: #2d2d44;
  --border-light: #3a3a5c;
  --success-color: #4caf50;
  --warning-color: #ff9800;
  --danger-color: #f44336;
  --info-color: #2196f3;
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-secondary: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-accent: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --gradient-dark: linear-gradient(135deg, #0c0c0c 0%, #1a1a2e 100%);
  --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.15);
  --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.25);
  --shadow-heavy: 0 15px 35px rgba(0, 0, 0, 0.35);
  --shadow-color: rgba(102, 192, 244, 0.3);
  --border-radius: 16px;
  --border-radius-small: 8px;
  --border-radius-large: 24px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease-out;
}

html {
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
  height: 100%;
  max-width: 100vw;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--background-color);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  height: 100%;
  position: relative;
  max-width: 100vw;
}

/* Enhanced animated background */
body {
  background: linear-gradient(-45deg, #0a0a15, #1a1a2e, #16213e, #0f0f23, #1e2a4a);
  background-size: 400% 400%;
  animation: gradientBG 20s ease infinite;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Viewport container to contain all animations */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: 
    radial-gradient(circle at 25% 25%, rgba(102, 192, 244, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(255, 200, 87, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(118, 75, 162, 0.05) 0%, transparent 70%);
  animation: float 30s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
  transform-origin: 50% 50%;
  will-change: transform;
  overflow: hidden;
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  25% { background-position: 100% 50%; }
  50% { background-position: 100% 100%; }
  75% { background-position: 0% 100%; }
  100% { background-position: 0% 50%; }
}

@keyframes float {
  0%, 100% { 
    transform: rotate(0deg) scale(0.98);
  }
  50% { 
    transform: rotate(45deg) scale(1.02);
  }
}

/* Floating icons for index page */
body::after {
  content: '🎮 🔒 ⚙️ 🛡️ 💻';
  position: fixed;
  top: 20%;
  right: -30px;
  font-size: 2.5rem;
  opacity: 0.05;
  transform: rotate(90deg);
  animation: floatIcons 25s infinite linear;
  pointer-events: none;
  z-index: 1;
  letter-spacing: 1.5rem;
  white-space: nowrap;
  transform-origin: 50% 50%;
  will-change: transform;
  overflow: hidden;
  max-width: 100px;
  max-height: 100vh;
}

@keyframes floatIcons {
  0% { 
    transform: rotate(90deg) translateY(0px);
    opacity: 0.05;
  }
  50% { 
    transform: rotate(90deg) translateY(-15px);
    opacity: 0.08;
  }
  100% { 
    transform: rotate(90deg) translateY(0px);
    opacity: 0.05;
  }
}

/* Enhanced fade in animation */
.fade-in {
  opacity: 0;
  animation: fadeIn 0.8s ease-out forwards;
  animation-delay: 0.1s;
}

@keyframes fadeIn {
  0% { 
    opacity: 0; 
    transform: translateY(20px) scale(0.98); 
  }
  100% { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
}

/* Safety fallback - ensure content is always visible */
.container:not(.fade-in) {
  opacity: 1;
  transform: none;
}

.main-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  z-index: 2;
}

.container {
  width: 100%;
  max-width: 500px;
  background: var(--card-color);
  border-radius: var(--border-radius-large);
  box-shadow: var(--shadow-heavy), 0 0 0 1px rgba(102, 192, 244, 0.1);
  overflow: hidden;
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  position: relative;
}

.container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
  z-index: 1;
}

.header {
  background: var(--gradient-primary);
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="8" height="8" patternUnits="userSpaceOnUse"><path d="M 8 0 L 0 0 0 8" fill="none" stroke="rgba(255,255,255,0.08)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
  opacity: 0.4;
  animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
  0% { transform: translateX(0) translateY(0); }
  100% { transform: translateX(8px) translateY(8px); }
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
  margin: 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 1;
  letter-spacing: -0.5px;
  text-transform: uppercase;
}

.content {
  padding: 2.5rem;
}

/* Enhanced modern error styles */
.error {
  padding: 1.5rem 2rem;
  border-radius: var(--border-radius);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  font-weight: 600;
  font-size: 15px;
  border-left: 5px solid var(--danger-color);
  animation: slideIn 0.5s ease-out, pulse 2s ease-in-out infinite;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.15), rgba(244, 67, 54, 0.08));
  color: #fff;
  border: 2px solid rgba(244, 67, 54, 0.4);
  box-shadow: var(--shadow-heavy), 0 0 20px rgba(244, 67, 54, 0.3);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.error svg {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: var(--danger-color);
  filter: drop-shadow(0 0 8px rgba(244, 67, 54, 0.5));
}

.error::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: translateX(-100%);
  animation: shimmer 3s infinite;
}

/* Inline error for JavaScript validation */
.error.inline {
  margin-bottom: 1rem;
  animation: slideIn 0.3s ease-out, shake 0.5s ease-in-out;
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.2), rgba(244, 67, 54, 0.1));
  border-color: var(--danger-color);
}

/* URL parameter error (from redirects) */
.error.url-error {
  animation: slideIn 0.5s ease-out, pulse 1.5s ease-in-out 3;
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.18), rgba(244, 67, 54, 0.12));
  border-left-width: 6px;
  box-shadow: var(--shadow-heavy), 0 0 25px rgba(244, 67, 54, 0.4);
}

.error.url-error::before {
  animation: shimmer 2s infinite;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes slideIn {
  0% {
    opacity: 0;
    transform: translateX(-30px) translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

/* Enhanced form elements */
.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.3px;
}

input[type="text"] {
  width: 100%;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--surface-color), var(--surface-elevated));
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
  transition: var(--transition);
  box-shadow: var(--shadow-light);
  position: relative;
  overflow: hidden;
}

input[type="text"]::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
  font-weight: 400;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(102, 192, 244, 0.2), var(--shadow-medium);
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--surface-elevated), var(--card-color));
}

input[type="text"]:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-medium);
}

/* Enhanced button styles */
button {
  width: 100%;
  padding: 18px 24px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--border-radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: var(--transition);
  margin-top: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-medium);
  font-family: inherit;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: var(--transition);
}

button:hover {
  background: linear-gradient(135deg, #5ab1e4, #4a9cd9);
  transform: translateY(-3px);
  box-shadow: var(--shadow-heavy), 0 0 25px var(--shadow-color);
}

button:hover::before {
  left: 100%;
}

button:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-medium);
}

button::after {
  content: '🚀';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  opacity: 0.8;
}

/* Enhanced footer */
.footer {
  text-align: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 13px;
  opacity: 0.8;
  position: relative;
}

.footer::before {
  content: '🔐';
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translateX(-50%);
  background: var(--card-color);
  padding: 0 10px;
  font-size: 20px;
}

/* Loading state for form submission */
.submit-button.loading {
  background: linear-gradient(135deg, #2c3e50, #34495e);
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
}

.submit-button.loading::after {
  content: '⏳';
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translateY(-50%) rotate(0deg); }
  100% { transform: translateY(-50%) rotate(360deg); }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
  .main-wrapper {
    padding: 15px;
    align-items: flex-start;
    padding-top: 30px;
  }

  .container {
    max-width: 100%;
    border-radius: var(--border-radius);
  }

  .header {
    padding: 2rem 1.5rem;
  }

  h1 {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  .content {
    padding: 2rem 1.5rem;
  }

  input[type="text"] {
    padding: 14px 18px;
    font-size: 15px;
  }

  button {
    padding: 16px 24px;
    font-size: 15px;
  }

  body::after {
    display: none; /* Hide floating icons on mobile */
  }
}

@media (max-width: 480px) {
  .main-wrapper {
    padding: 10px;
    padding-top: 20px;
  }

  .header {
    padding: 1.5rem 1rem;
  }

  h1 {
    font-size: 1.3rem;
  }

  .content {
    padding: 1.5rem 1rem;
  }

  input[type="text"] {
    padding: 12px 16px;
    font-size: 14px;
    letter-spacing: 1px;
  }

  button {
    padding: 14px 20px;
    font-size: 14px;
  }

  .footer {
    font-size: 12px;
  }
}

/* Enhanced animations for modern feel */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  body::before,
  body::after {
    animation: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --text-primary: #ffffff;
    --text-secondary: #ffffff;
    --border-color: #ffffff;
    --primary-color: #00ffff;
  }
}

/* Dark mode refinements */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #ffffff;
    --background-color: #000000;
  }
}