:root {
  --primary: #00e5ff;
  --secondary: #ff2d75;
  --dark: #0f172a;
  --darker: #020617;
  --light: #f8fafc;
  --code-bg: #1e293b;
  --correct: #10b981;
  --wrong: #ef4444;
  --sidebar: #1e293b;
  --glass: rgba(255, 255, 255, 0.05);
  --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: var(--dark);
  color: var(--light);
  min-height: 100vh;
  display: flex;
  line-height: 1.6;
  overflow-x: hidden;
}

.animated-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background: linear-gradient(135deg, var(--darker) 0%, var(--dark) 100%);
  overflow: hidden;
}

.animated-bg::before {
  content: "";
  position: absolute;
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  background: 
    radial-gradient(circle at 30% 30%, 
      rgba(0, 229, 255, 0.15) 0%, 
      transparent 20%),
    radial-gradient(circle at 70% 70%, 
      rgba(255, 45, 117, 0.15) 0%, 
      transparent 20%);
  background-size: 200px 200px;
  animation: moveBg 120s linear infinite;
  opacity: 0.8;
}

@keyframes moveBg {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.particle {
  position: absolute;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.3;
  filter: blur(1px);
  animation: float 15s infinite linear;
}

@keyframes float {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.3; }
  90% { opacity: 0.3; }
  100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
}

aside {
  width: 300px;
  background: rgba(30, 41, 59, 0.8);
  padding: 2rem 1.5rem;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  box-shadow: 5px 0 30px rgba(0, 0, 0, 0.3);
  transition: var(--transition);
  z-index: 10;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideInLeft 0.6s ease-out;
}

.sidebar-header h2 {
  font-size: 1.5rem;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 10px rgba(0, 229, 255, 0.3);
}

.dashboard-section {
  margin-bottom: 2rem;
  animation: fadeIn 0.8s ease-out;
  animation-fill-mode: backwards;
}

.dashboard-section h3 {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

select {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  font-family: 'Inter', sans-serif;
  margin-bottom: 1rem;
  transition: var(--transition);
}

select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.2);
}

.timer-container {
  background: var(--glass);
  padding: 1.25rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  transition: var(--transition);
}

.timer-container:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.timer-display {
  font-size: 2.25rem;
  font-family: 'Fira Code', monospace;
  text-align: center;
  margin: 0.5rem 0;
  color: var(--primary);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
  font-weight: 700;
}

.timer-controls {
  display: flex;
  gap: 0.75rem;
}

.timer-btn {
  flex: 1;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: rgba(0, 229, 255, 0.1);
  color: white;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.timer-btn:hover {
  background: rgba(0, 229, 255, 0.2);
  transform: translateY(-2px);
}

.timer-btn.active {
  background: var(--primary);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.stats-container {
  background: var(--glass);
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}

.stat-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.stat-label {
  color: rgba(255, 255, 255, 0.7);
}

.stat-value {
  font-weight: 600;
  color: var(--light);
}

.leaderboard-container {
  background: var(--glass);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
}

.leaderboard-entry:last-child {
  border-bottom: none;
}

.leaderboard-rank {
  color: var(--primary);
  font-weight: 600;
  width: 2rem;
}

.leaderboard-name {
  flex: 1;
  text-align: left;
  padding: 0 0.5rem;
}

.leaderboard-score {
  color: var(--secondary);
  font-weight: 600;
  font-family: 'Fira Code', monospace;
}

.leaderboard-language {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  width: 3rem;
  text-align: right;
}

.leaderboard-loading {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

main {
  flex: 1;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.game-title {
  text-align: center;
  margin-bottom: 2.5rem;
  animation: fadeInDown 0.8s ease-out;
}

.game-title h1 {
  font-size: 3rem;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.5rem;
  text-shadow: 0 5px 15px rgba(0, 229, 255, 0.3);
  animation: textGlow 2s ease-in-out infinite alternate;
}

.game-title p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

@keyframes textGlow {
  from { text-shadow: 0 0 10px rgba(0, 229, 255, 0.5); }
  to { text-shadow: 0 0 20px rgba(0, 229, 255, 0.8), 0 0 30px rgba(255, 45, 117, 0.5); }
}

.snippet-wrapper {
  width: 100%;
  max-width: 800px;
  display: flex;
  justify-content: center;
  perspective: 1000px;
}

.code-container {
  background: var(--code-bg);
  padding: 2rem;
  border-radius: 16px;
  width: 100%;
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  margin: 1rem 0;
  overflow-x: auto;
  transform-style: preserve-3d;
  transition: var(--transition);
  animation: fadeInUp 0.8s ease-out;
}

.code-container:hover {
  transform: translateY(-5px) rotateX(2deg);
  box-shadow: 
    0 15px 40px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.code-line {
  display: flex;
  padding: 0.5rem 1rem;
  margin: 0.25rem 0;
  font-family: 'Fira Code', 'Consolas', monospace;
  white-space: pre;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  position: relative;
}

.code-line:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(5px);
}

.line-number {
  color: rgba(255, 255, 255, 0.3);
  margin-right: 1rem;
  width: 2rem;
  text-align: right;
  font-size: 0.85rem;
  user-select: none;
}

.code-content {
  flex: 1;
  overflow-x: auto;
}

.correct {
  background: var(--correct);
  animation: pulseCorrect 0.6s ease;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.correct .line-number {
  color: white;
  font-weight: bold;
}

.wrong {
  background: var(--wrong);
  animation: shake 0.5s ease;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.wrong .line-number {
  color: white;
  font-weight: bold;
}

@keyframes pulseCorrect {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); box-shadow: 0 0 25px rgba(16, 185, 129, 0.5); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.feedback-message {
  margin: 1.5rem 0;
  padding: 1.25rem;
  border-radius: 12px;
  background: var(--glass);
  width: 100%;
  max-width: 800px;
  text-align: center;
  transition: var(--transition);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: fadeIn 0.8s ease-out;
}

.game-controls {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.next-button, .hint-button {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.next-button {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: 
    0 5px 15px rgba(0, 229, 255, 0.3),
    0 2px 5px rgba(255, 45, 117, 0.3);
}

.hint-button {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.next-button:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 
    0 8px 25px rgba(0, 229, 255, 0.4),
    0 5px 10px rgba(255, 45, 117, 0.4);
}

.hint-button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
}

.next-button:active, .hint-button:active {
  transform: translateY(1px);
}

/* Leaderboard Modal Styles */
.leaderboard-modal {
  background: var(--glass);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 800px;
  margin: 2rem auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: fadeInUp 0.8s ease-out;
}

.leaderboard-header {
  text-align: center;
  margin-bottom: 2rem;
}

.leaderboard-header h2 {
  color: var(--primary);
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.leaderboard-header p {
  font-size: 1.5rem;
  color: var(--secondary);
  font-weight: bold;
}

.leaderboard-content h3 {
  color: var(--primary);
  margin-bottom: 1rem;
  text-align: center;
  font-size: 1.5rem;
}

.leaderboard-entries {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 2rem;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: 50px 2fr 100px 100px 150px;
  gap: 1rem;
  padding: 1rem;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.leaderboard-entry:nth-child(1) {
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.1), transparent);
  border-left: 4px solid gold;
}

.leaderboard-entry:nth-child(2) {
  background: linear-gradient(90deg, rgba(192, 192, 192, 0.1), transparent);
  border-left: 4px solid silver;
}

.leaderboard-entry:nth-child(3) {
  background: linear-gradient(90deg, rgba(205, 127, 50, 0.1), transparent);
  border-left: 4px solid #cd7f32;
}

.rank {
  font-weight: bold;
  color: var(--primary);
  text-align: center;
}

.name {
  font-weight: 500;
}

.score {
  font-weight: bold;
  color: var(--secondary);
  text-align: center;
}

.language {
  text-transform: uppercase;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
}

.date {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  text-align: right;
}

.leaderboard-actions {
  display: flex;
  justify-content: center;
}

/* Hint animation */
@keyframes pulseHint {
  0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

/* Scrollbar styles */
.leaderboard-entries::-webkit-scrollbar {
  width: 8px;
}

.leaderboard-entries::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

.leaderboard-entries::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}

.leaderboard-entries::-webkit-scrollbar-thumb:hover {
  background: var(--secondary);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 1024px) {
  aside {
    width: 260px;
    padding: 1.5rem 1rem;
  }
  
  main {
    padding: 2rem;
  }
  
  .game-title h1 {
    font-size: 2.5rem;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  aside {
    width: 100%;
    height: auto;
    position: relative;
    padding: 1.5rem;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  main {
    padding: 2rem 1.5rem;
  }

  .game-title h1 {
    font-size: 2rem;
  }
  
  .timer-display {
    font-size: 1.75rem;
  }
  
  .code-container {
    padding: 1.5rem;
  }

  .leaderboard-entry {
    grid-template-columns: 40px 1fr 80px 80px;
  }
  .date {
    display: none;
  }
}

@media (max-width: 480px) {
  .game-title h1 {
    font-size: 1.8rem;
  }
  
  .next-button, .hint-button {
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
  }
  
  .code-line {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
  
  .line-number {
    margin-right: 0.5rem;
    width: 1.5rem;
  }

  .leaderboard-entry {
    grid-template-columns: 30px 1fr 70px;
  }
  .language {
    display: none;
  }
}