/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --dark-gradient: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --shadow-primary: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 12px 40px rgba(102, 126, 234, 0.3);
  --border-radius: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: "Jersey 15", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  min-height: 100vh;
  color: #333;
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
}

/* Animated background */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Glass morphism container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

/* Header Styles */
header {
  text-align: center;
  margin-bottom: 40px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  padding: 40px 30px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-primary);
  position: relative;
  overflow: hidden;
}

header::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

header h1 {
  font-family: "Coral Pixels", monospace;
  font-size: 3.5rem;
  font-weight: 400;
  color: #ffffff;
  margin-bottom: 15px;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.5),
    0 0 40px rgba(102, 126, 234, 0.3);
  letter-spacing: 3px;
  position: relative;
  z-index: 1;
}

header p {
  font-family: "Jersey 10", monospace;
  font-size: 1.4rem;
  color: rgba(255, 255, 255, 0.9);
  max-width: 600px;
  margin: 0 auto;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1;
}

/* Controls Section */
.controls {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  padding: 35px;
  border-radius: var(--border-radius);
  margin-bottom: 30px;
  box-shadow: var(--shadow-primary);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 25px;
  align-items: end;
  position: relative;
  overflow: hidden;
}

.controls::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 70%
  );
  animation: float 6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes float {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  50% {
    transform: translate(-50%, -50%) rotate(180deg);
  }
}

.input-group {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.input-group label {
  font-family: "Bytesized", monospace;
  font-weight: 400;
  color: #ffffff;
  margin-bottom: 12px;
  font-size: 1.2rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: 1px;
}

.input-group input,
.input-group select {
  font-family: "Jersey 10", monospace;
  padding: 15px 20px;
  border: 2px solid var(--glass-border);
  border-radius: 15px;
  font-size: 1.1rem;
  transition: var(--transition);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

.input-group input::placeholder {
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2),
    inset 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.25);
}

.input-group input {
  font-weight: bold;
  letter-spacing: 2px;
}

.input-group select option {
  background: #2c3e50;
  color: white;
  font-family: "Jersey 10", monospace;
}

/* Buttons */
.generate-btn,
.clear-btn {
  grid-column: span 3;
  font-family: "Jacquard 12", monospace;
  padding: 18px 35px;
  border: none;
  border-radius: 15px;
  font-size: 1.2rem;
  font-weight: 400;
  cursor: pointer;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 2px;
  position: relative;
  overflow: hidden;
  z-index: 1;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.generate-btn::before,
.clear-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: var(--transition);
  z-index: -1;
}

.generate-btn:hover::before,
.clear-btn:hover::before {
  left: 100%;
}

.generate-btn {
  background: var(--accent-gradient);
  color: white;
  margin-right: 15px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  box-shadow: 0 8px 25px rgba(79, 172, 254, 0.4);
}

.generate-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(79, 172, 254, 0.6);
  border-color: rgba(255, 255, 255, 0.6);
}

.generate-btn:active {
  transform: translateY(-1px);
}

.clear-btn {
  background: var(--secondary-gradient);
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  box-shadow: 0 8px 25px rgba(240, 147, 251, 0.4);
}

.clear-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(240, 147, 251, 0.6);
  border-color: rgba(255, 255, 255, 0.6);
}

.clear-btn:active {
  transform: translateY(-1px);
}

/* Display Area */
.display-area {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  padding: 50px 40px;
  border-radius: var(--border-radius);
  margin-bottom: 30px;
  box-shadow: var(--shadow-primary);
  min-height: 220px;
  position: relative;
  overflow: hidden;
}

.display-area::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 50%
  );
  pointer-events: none;
}

.number-display {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 140px;
  position: relative;
  z-index: 1;
}

.placeholder {
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  position: relative;
  z-index: 1;
}

.placeholder span {
  font-size: 5rem;
  display: block;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.5));
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.8;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

.placeholder p {
  font-family: "Jersey 10", monospace;
  font-size: 1.4rem;
  font-style: italic;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.digit {
  max-width: 90px;
  max-height: 130px;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: var(--transition);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3))
    drop-shadow(0 0 20px rgba(255, 255, 255, 0.2));
  border-radius: 8px;
}

.digit:hover {
  transform: scale(1.15) rotate(2deg);
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.4))
    drop-shadow(0 0 30px rgba(255, 255, 255, 0.4));
}

/* Info Section */
.info {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 30px;
  margin-bottom: 30px;
}

.stats {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  padding: 30px;
  border-radius: 18px;
  box-shadow: var(--shadow-primary);
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

.stats::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, #f093fb, #f5576c, #4facfe, #00f2fe);
  border-radius: 18px;
  z-index: -1;
  animation: borderGlow 4s linear infinite;
}

@keyframes borderGlow {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

.stats span {
  font-family: "Tiny5", monospace;
  font-size: 1.3rem;
  font-weight: 400;
  color: #ffffff;
  padding: 15px 20px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  border-left: 4px solid rgba(255, 255, 255, 0.6);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: var(--transition);
  position: relative;
  z-index: 1;
}

.stats span:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateX(5px);
}

.instructions {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  padding: 30px;
  border-radius: 18px;
  box-shadow: var(--shadow-primary);
  position: relative;
  overflow: hidden;
}

.instructions::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
}

.instructions h3 {
  font-family: "Jersey 25", monospace;
  color: #ffffff;
  margin-bottom: 20px;
  font-size: 1.6rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  letter-spacing: 1px;
}

.instructions ul {
  list-style: none;
  padding-left: 0;
}

.instructions li {
  font-family: "Jersey 10", monospace;
  padding: 12px 0;
  padding-left: 35px;
  position: relative;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.1rem;
  transition: var(--transition);
}

.instructions li:hover {
  color: #ffffff;
  transform: translateX(5px);
}

.instructions li::before {
  content: "▶";
  position: absolute;
  left: 0;
  color: #00f2fe;
  font-weight: bold;
  font-size: 1.2rem;
  text-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
  animation: blink 2s infinite;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0.5;
  }
}

/* Footer */
footer {
  text-align: center;
  padding: 25px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  color: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  margin-top: 20px;
  font-family: "Jacquarda Bastarda 9", monospace;
  font-size: 1.2rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

footer::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-gradient);
}

/* Loading Animation */
.loading {
  display: inline-block;
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid #00f2fe;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  filter: drop-shadow(0 0 20px rgba(0, 242, 254, 0.5));
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Message States */
.error {
  font-family: "Jersey 10", monospace;
  color: #ffffff;
  background: rgba(231, 76, 60, 0.2);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: 20px;
  border-radius: 15px;
  border: 2px solid rgba(231, 76, 60, 0.5);
  margin: 20px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  box-shadow: 0 8px 25px rgba(231, 76, 60, 0.3);
}

.success {
  font-family: "Jersey 10", monospace;
  color: #ffffff;
  background: rgba(39, 174, 96, 0.2);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: 20px;
  border-radius: 15px;
  border: 2px solid rgba(39, 174, 96, 0.5);
  margin: 20px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  box-shadow: 0 8px 25px rgba(39, 174, 96, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  header {
    padding: 25px 20px;
  }

  header h1 {
    font-size: 2.5rem;
    letter-spacing: 2px;
  }

  header p {
    font-size: 1.1rem;
  }

  .controls {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 25px;
  }

  .generate-btn,
  .clear-btn {
    grid-column: span 1;
    margin: 8px 0;
    padding: 15px 25px;
    font-size: 1rem;
  }

  .info {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .digit {
    max-width: 70px;
    max-height: 100px;
  }

  .display-area {
    padding: 30px 20px;
  }

  .stats {
    text-align: center;
  }

  .stats span {
    font-size: 1.1rem;
  }

  .instructions h3 {
    font-size: 1.4rem;
  }

  .instructions li {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  header {
    padding: 20px 15px;
  }

  header h1 {
    font-size: 2rem;
    letter-spacing: 1px;
  }

  header p {
    font-size: 1rem;
  }

  .controls {
    padding: 20px;
  }

  .digit {
    max-width: 55px;
    max-height: 80px;
  }

  .placeholder span {
    font-size: 3.5rem;
  }

  .display-area {
    padding: 25px 15px;
  }

  .stats span {
    font-size: 1rem;
    padding: 12px 15px;
  }

  .instructions h3 {
    font-size: 1.2rem;
  }

  .instructions li {
    font-size: 0.95rem;
    padding: 10px 0 10px 30px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .digit {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
  :root {
    --glass-bg: rgba(0, 0, 0, 0.2);
    --glass-border: rgba(255, 255, 255, 0.1);
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .container::before {
    animation: none;
  }

  body {
    animation: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
}

/* Animation for digit appearance */
@keyframes digitAppear {
  from {
    opacity: 0;
    transform: scale(0.3) rotate(-15deg) translateY(30px);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg) translateY(0px);
    filter: blur(0px);
  }
}

.digit-appear {
  animation: digitAppear 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Enhanced pulse animation for generate button */
.pulse {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(79, 172, 254, 0.7);
    transform: scale(1);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(79, 172, 254, 0);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(79, 172, 254, 0);
    transform: scale(1);
  }
}

/* Glitch effect for title */
@keyframes glitch {
  0% {
    transform: translate(0);
  }
  20% {
    transform: translate(-2px, 2px);
  }
  40% {
    transform: translate(-2px, -2px);
  }
  60% {
    transform: translate(2px, 2px);
  }
  80% {
    transform: translate(2px, -2px);
  }
  100% {
    transform: translate(0);
  }
}

header h1:hover {
  animation: glitch 0.3s ease-in-out;
}

/* Floating particles effect */
.container::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(
      2px 2px at 20px 30px,
      rgba(255, 255, 255, 0.3),
      transparent
    ),
    radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(
      1px 1px at 130px 80px,
      rgba(255, 255, 255, 0.3),
      transparent
    ),
    radial-gradient(
      2px 2px at 160px 30px,
      rgba(255, 255, 255, 0.2),
      transparent
    );
  background-repeat: repeat;
  background-size: 200px 100px;
  animation: particleFloat 20s linear infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes particleFloat {
  0% {
    transform: translateY(0) translateX(0);
  }
  100% {
    transform: translateY(-100vh) translateX(100px);
  }
}
