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

:root {
  --bg-primary: #0f0f23;
  --bg-secondary: #1a1a3e;
  --accent-cyan: #00d4ff;
  --accent-magenta: #ff00ff;
  --accent-purple: #8b5cf6;
  --accent-green: #00ff88;
  --text-primary: #ffffff;
  --text-secondary: #a0a0c0;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.background {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, #1e1e4a 100%);
  overflow: hidden;
  z-index: 0;
}

.floating-orb {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.3) 0%, transparent 70%);
  filter: blur(40px);
  animation: float 20s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(100vh) scale(1); opacity: 0.3; }
  50% { transform: translateY(-100vh) scale(1.2); opacity: 0.6; }
}

.header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(15, 15, 35, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(139, 92, 246, 0.3);
}

.menu-btn {
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: var(--accent-purple);
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.menu-btn:hover {
  background: rgba(139, 92, 246, 0.4);
  transform: scale(1.05);
}

.title {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
}

.progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.progress-bar {
  width: 120px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
  z-index: 5;
}

.main.shuffling .card-wrapper {
  animation: shuffle 0.8s ease-in-out;
}

@keyframes shuffle {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(0.8) rotate(-10deg) translateX(-50px); }
  50% { transform: scale(0.6) rotate(10deg) translateY(-30px); }
  75% { transform: scale(0.8) rotate(-5deg) translateX(50px); }
  100% { transform: scale(1) rotate(0deg); }
}

.deck-title {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.card-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  perspective: 2000px;
}

.card-wrapper.slide-in-right { animation: slideInRight 0.5s ease-out; }
.card-wrapper.slide-in-left { animation: slideInLeft 0.5s ease-out; }
.card-wrapper.scale-in { animation: scaleIn 0.5s ease-out; }
.card-wrapper.rotate-in { animation: rotateIn 0.5s ease-out; }
.card-wrapper.flip-in { animation: flipIn 0.6s ease-out; }

@keyframes slideInRight {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInLeft {
  from { transform: translateX(-100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes rotateIn {
  from { transform: rotate(-180deg) scale(0.5); opacity: 0; }
  to { transform: rotate(0) scale(1); opacity: 1; }
}

@keyframes flipIn {
  from { transform: rotateY(-90deg); opacity: 0; }
  to { transform: rotateY(0); opacity: 1; }
}

.nav-btn {
  background: rgba(139, 92, 246, 0.2);
  border: 2px solid rgba(139, 92, 246, 0.4);
  color: var(--accent-purple);
  font-size: 2.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  background: rgba(139, 92, 246, 0.4);
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}

.nav-btn:active {
  transform: scale(0.95);
}

.flashcard-container {
  width: min(400px, 85vw);
  height: min(280px, 50vh);
  cursor: pointer;
  transition: transform 0.15s ease-out;
}

.flashcard-container:hover {
  animation: wobble 0.5s ease-in-out;
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

.flashcard-container.card-success {
  animation: cardSuccess 0.8s ease-out forwards;
}

.flashcard-container.card-shake {
  animation: cardShake 0.5s ease-out;
}

@keyframes cardSuccess {
  0% { transform: scale(1) rotate(0deg); }
  30% { transform: scale(0.9) rotate(10deg); }
  60% { transform: scale(0.7) rotate(-5deg) translateY(-50px); }
  100% { transform: scale(0.3) rotate(720deg) translateY(-200px); opacity: 0; }
}

@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
  20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.flashcard-front {
  background: linear-gradient(135deg, #1e1e4a 0%, #2d2d6a 100%);
  border: 2px solid rgba(0, 212, 255, 0.3);
}

.flashcard-back {
  background: linear-gradient(135deg, #2d1e4a 0%, #4a2d6a 100%);
  border: 2px solid rgba(255, 0, 255, 0.3);
  transform: rotateY(180deg);
}

.card-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-label {
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--accent-cyan);
}

.flashcard-back .card-label {
  color: var(--accent-magenta);
}

.card-content p {
  font-size: 1.2rem;
  line-height: 1.6;
  font-weight: 500;
}

.card-counter {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.controls {
  position: relative;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: rgba(15, 15, 35, 0.8);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(139, 92, 246, 0.3);
}

.btn {
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.btn-success {
  background: linear-gradient(135deg, #00ff88 0%, #00cc6a 100%);
  color: #000;
  border-color: #00ff88;
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 255, 136, 0.4);
}

.btn-warning {
  background: linear-gradient(135deg, #ff9500 0%, #ff6b00 100%);
  color: #000;
  border-color: #ff9500;
}

.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(255, 149, 0, 0.4);
}

.btn-shuffle, .btn-add, .btn-reset {
  background: rgba(139, 92, 246, 0.2);
  color: var(--accent-purple);
  border-color: rgba(139, 92, 246, 0.4);
}

.btn-shuffle:hover, .btn-add:hover, .btn-reset:hover {
  background: rgba(139, 92, 246, 0.4);
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-purple) 100%);
  color: white;
}

.empty-deck {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.empty-deck p {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: min(320px, 85vw);
  height: 100vh;
  background: rgba(15, 15, 35, 0.98);
  backdrop-filter: blur(30px);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid rgba(139, 92, 246, 0.3);
  display: flex;
  flex-direction: column;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.sidebar-header h3 {
  font-size: 1.2rem;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 2rem;
  cursor: pointer;
  transition: color 0.3s;
}

.sidebar-close:hover {
  color: var(--accent-magenta);
}

.deck-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.deck-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.deck-item:hover {
  background: rgba(139, 92, 246, 0.2);
  transform: translateX(5px) rotateY(-2deg);
}

.deck-item.active {
  background: rgba(0, 212, 255, 0.2);
  border-color: var(--accent-cyan);
}

.deck-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.deck-name {
  font-weight: 600;
}

.deck-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.deck-delete {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.3s;
}

.deck-delete:hover {
  opacity: 1;
}

.btn-add-deck {
  width: calc(100% - 2rem);
  margin: 1rem;
  padding: 1rem;
  background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-magenta) 100%);
  border: none;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-add-deck:hover {
  transform: scale(1.02);
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.4);
}

.add-deck-form {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.add-deck-form input {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 8px;
  color: white;
  font-family: 'Space Grotesk', sans-serif;
}

.add-deck-form input:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

.add-deck-actions {
  display: flex;
  gap: 0.5rem;
}

.add-deck-actions button {
  flex: 1;
  padding: 0.5rem;
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  transition: all 0.3s;
}

.add-deck-actions button:first-child {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--text-secondary);
}

.add-deck-actions button:last-child {
  background: var(--accent-purple);
  border: none;
  color: white;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: rgba(26, 26, 62, 0.95);
  backdrop-filter: blur(30px);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 24px;
  width: min(450px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.modal-header h2 {
  font-size: 1.3rem;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

.card-form {
  padding: 1.5rem;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-group textarea {
  width: 100%;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 12px;
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  resize: vertical;
  transition: border-color 0.3s;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

.preview-section {
  margin: 1.5rem 0;
  text-align: center;
}

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

.mini-card {
  width: 200px;
  height: 120px;
  margin: 0 auto;
  perspective: 1000px;
  cursor: pointer;
}

.mini-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s;
}

.mini-card.flipped .mini-card-inner {
  transform: rotateY(180deg);
}

.mini-card-front, .mini-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-size: 0.85rem;
  text-align: center;
  overflow: hidden;
}

.mini-card-front {
  background: linear-gradient(135deg, #1e1e4a 0%, #2d2d6a 100%);
  border: 1px solid rgba(0, 212, 255, 0.3);
}

.mini-card-back {
  background: linear-gradient(135deg, #2d1e4a 0%, #4a2d6a 100%);
  border: 1px solid rgba(255, 0, 255, 0.3);
  transform: rotateY(180deg);
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.form-actions .btn {
  flex: 1;
}

.btn-cancel {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--text-secondary);
}

.btn-save {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-purple) 100%);
  color: white;
}

.btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Particles */
.particle-container {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
}

.particle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: particleBurst 1s ease-out forwards;
}

@keyframes particleBurst {
  0% {
    transform: scale(1) translate(0, 0);
    opacity: 1;
  }
  100% {
    transform: scale(0) translate(
      calc((var(--x, 0) - 0.5) * 200px),
      calc((var(--y, 0) - 0.5) * 200px - 100px)
    );
    opacity: 0;
  }
}

.particle:nth-child(1) { --x: 0.1; --y: 0.2; }
.particle:nth-child(2) { --x: 0.9; --y: 0.3; }
.particle:nth-child(3) { --x: 0.2; --y: 0.8; }
.particle:nth-child(4) { --x: 0.8; --y: 0.9; }
.particle:nth-child(5) { --x: 0.5; --y: 0.1; }
.particle:nth-child(6) { --x: 0.3; --y: 0.6; }
.particle:nth-child(7) { --x: 0.7; --y: 0.4; }
.particle:nth-child(8) { --x: 0.4; --y: 0.7; }
.particle:nth-child(9) { --x: 0.6; --y: 0.2; }
.particle:nth-child(10) { --x: 0.2; --y: 0.4; }
.particle:nth-child(11) { --x: 0.8; --y: 0.6; }
.particle:nth-child(12) { --x: 0.1; --y: 0.9; }
.particle:nth-child(13) { --x: 0.9; --y: 0.1; }
.particle:nth-child(14) { --x: 0.5; --y: 0.5; }
.particle:nth-child(15) { --x: 0.3; --y: 0.3; }
.particle:nth-child(16) { --x: 0.7; --y: 0.7; }
.particle:nth-child(17) { --x: 0.4; --y: 0.1; }
.particle:nth-child(18) { --x: 0.6; --y: 0.9; }
.particle:nth-child(19) { --x: 0.2; --y: 0.5; }
.particle:nth-child(20) { --x: 0.8; --y: 0.5; }

/* Footer */
.footer {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: rgba(15, 15, 35, 0.6);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.footer a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: color 0.3s;
}

.footer a:hover {
  color: var(--accent-magenta);
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .header {
    padding: 0.75rem 1rem;
  }
  
  .title {
    font-size: 1.2rem;
  }
  
  .progress-bar {
    width: 80px;
  }
  
  .card-wrapper {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .nav-btn {
    display: none;
  }
  
  .flashcard-container {
    width: 90vw;
    height: 45vh;
  }
  
  .card-content p {
    font-size: 1rem;
  }
  
  .controls {
    padding: 1rem;
    gap: 0.5rem;
  }
  
  .btn {
    padding: 0.6rem 0.9rem;
    font-size: 0.8rem;
  }
  
  .footer span:first-child {
    display: none;
  }
  
  .sidebar {
    width: 100vw;
  }
}

/* Touch swipe hint for mobile */
@media (max-width: 640px) {
  .card-wrapper::after {
    content: '← swipe →';
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.5;
  }
}