@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;700&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
  --bg: #0a0e14;
  --bg-card: #131820;
  --bg-card-hover: #1a2130;
  --green: #00ff9c;
  --green-dim: #00cc7a;
  --green-glow: rgba(0, 255, 156, 0.15);
  --blue: #00d4ff;
  --blue-dim: #00a8cc;
  --yellow: #ffd700;
  --red: #ff4757;
  --orange: #ff9f43;
  --text: #c5cdd9;
  --text-dim: #6b7a8d;
  --border: #1e2a3a;
  --border-glow: rgba(0, 255, 156, 0.3);
  --font-mono: 'Fira Code', 'JetBrains Mono', 'Courier New', monospace;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Scanline overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Grid background */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(0, 255, 156, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 156, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: -1;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  position: relative;
  z-index: 1;
}

/* Terminal window */
.terminal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 255, 156, 0.05);
  margin-bottom: 2rem;
}

.terminal-header {
  background: #1a2130;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.terminal-dot.red { background: #ff5f57; }
.terminal-dot.yellow { background: #febc2e; }
.terminal-dot.green { background: #28c840; }

.terminal-title {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-left: 0.5rem;
  flex: 1;
}

.terminal-body {
  padding: 2rem;
}

/* Progress bar */
.progress-container {
  margin-bottom: 2rem;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px var(--green-glow);
}

.progress-steps {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.progress-step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-dim);
  transition: all 0.3s ease;
}

.progress-step.active {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 10px var(--green-glow);
}

.progress-step.completed {
  background: var(--green);
  border-color: var(--green);
  color: var(--bg);
}

/* Timer */
.timer {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 1.1rem;
  color: var(--green);
  font-family: var(--font-mono);
  z-index: 100;
  box-shadow: 0 0 20px rgba(0, 255, 156, 0.1);
}

.timer-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Typing effect */
.typing-text {
  overflow: hidden;
  white-space: normal;
}

.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--green);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Riddle text */
.riddle {
  font-size: 1.1rem;
  color: var(--blue);
  line-height: 1.8;
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 3px solid var(--blue);
  background: rgba(0, 212, 255, 0.05);
  border-radius: 0 8px 8px 0;
}

.riddle em {
  color: var(--yellow);
  font-style: normal;
}

/* Code block */
.code-block {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin: 1rem 0;
  font-size: 0.9rem;
  overflow-x: auto;
}

.code-block .comment { color: var(--text-dim); }
.code-block .keyword { color: var(--purple, #c678dd); }
.code-block .string { color: var(--green); }
.code-block .function { color: var(--blue); }
.code-block .variable { color: var(--orange); }
.code-block .number { color: var(--yellow); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border: 1px solid var(--green);
  background: transparent;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--green);
  color: var(--bg);
  box-shadow: 0 0 20px var(--green-glow);
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--green);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--green-dim);
  box-shadow: 0 0 30px var(--green-glow);
}

.btn-blue {
  border-color: var(--blue);
  color: var(--blue);
}

.btn-blue:hover {
  background: var(--blue);
  color: var(--bg);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

/* Status badge */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-success {
  background: rgba(0, 255, 156, 0.1);
  color: var(--green);
  border: 1px solid rgba(0, 255, 156, 0.3);
}

.status-info {
  background: rgba(0, 212, 255, 0.1);
  color: var(--blue);
  border: 1px solid rgba(0, 212, 255, 0.3);
}

.status-warning {
  background: rgba(255, 215, 0, 0.1);
  color: var(--yellow);
  border: 1px solid rgba(255, 215, 0, 0.3);
}

/* ASCII art */
.ascii-art {
  font-size: 0.6rem;
  line-height: 1.2;
  color: var(--green);
  text-align: center;
  margin: 1.5rem 0;
  opacity: 0.8;
  white-space: pre;
}

/* Title */
.title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 0.5rem;
  text-shadow: 0 0 30px var(--green-glow);
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Checkpoint number */
.checkpoint-num {
  font-size: 4rem;
  font-weight: 700;
  color: var(--green);
  opacity: 0.15;
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  line-height: 1;
}

/* Input */
.input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 0.7rem 1rem;
  border-radius: 6px;
  width: 100%;
  outline: none;
  transition: border-color 0.3s;
}

.input:focus {
  border-color: var(--green);
  box-shadow: 0 0 10px var(--green-glow);
}

.input-group {
  margin: 1rem 0;
}

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

/* Leaderboard */
.leaderboard {
  margin: 1.5rem 0;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.leaderboard-row:hover {
  background: var(--bg-card-hover);
}

.leaderboard-row.highlight {
  background: rgba(0, 255, 156, 0.05);
  border: 1px solid rgba(0, 255, 156, 0.2);
  border-radius: 6px;
}

.leaderboard-rank {
  width: 40px;
  font-size: 1.2rem;
  font-weight: 700;
}

.leaderboard-rank.gold { color: var(--yellow); }
.leaderboard-rank.silver { color: #c0c0c0; }
.leaderboard-rank.bronze { color: #cd7f32; }

.leaderboard-name {
  flex: 1;
  font-size: 0.9rem;
}

.leaderboard-time {
  font-size: 0.9rem;
  color: var(--green);
  font-weight: 500;
}

/* Glitch effect */
@keyframes glitch {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
}

.glitch {
  animation: glitch 0.3s ease-in-out;
}

/* Pulse */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Glow */
@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px var(--green-glow); }
  50% { box-shadow: 0 0 20px var(--green-glow), 0 0 40px rgba(0, 255, 156, 0.1); }
}

.glow {
  animation: glow 2s ease-in-out infinite;
}

/* Fade in */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.fade-in-delay-1 { animation-delay: 0.1s; opacity: 0; }
.fade-in-delay-2 { animation-delay: 0.2s; opacity: 0; }
.fade-in-delay-3 { animation-delay: 0.3s; opacity: 0; }
.fade-in-delay-4 { animation-delay: 0.4s; opacity: 0; }
.fade-in-delay-5 { animation-delay: 0.5s; opacity: 0; }

/* Digit display */
.digit-display {
  text-align: center;
  margin: 2rem 0;
}

.digit {
  font-size: 5rem;
  font-weight: 700;
  color: var(--yellow);
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
  display: inline-block;
  animation: digitReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Password display */
.password-display {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.password-digit {
  width: 60px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-dim);
  transition: all 0.3s ease;
}

.password-digit.filled {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 15px var(--green-glow);
}

.my-numbers-list {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.my-num {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--green);
  border: 2px solid var(--green);
  border-radius: 8px;
  background: var(--bg);
  animation: digitReveal 0.4s cubic-bezier(0.34,1.56,0.64,1) backwards;
}

.my-num:nth-child(1) { animation-delay: 0.1s; }
.my-num:nth-child(2) { animation-delay: 0.2s; }
.my-num:nth-child(3) { animation-delay: 0.3s; }
.my-num:nth-child(4) { animation-delay: 0.4s; }
.my-num:nth-child(5) { animation-delay: 0.5s; }

.password-digit.active {
  border-color: var(--yellow);
  color: var(--yellow);
  animation: pulse 1s ease-in-out infinite;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 1rem;
  }

  .terminal-body {
    padding: 1.5rem 1rem;
  }

  .title {
    font-size: 1.4rem;
  }

  .ascii-art {
    font-size: 0.4rem;
  }

  .timer {
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
  }

  .password-digit {
    width: 48px;
    height: 56px;
    font-size: 1.5rem;
  }
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9998;
}

/* Hint toggle */
.hint-toggle {
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.2s;
}

.hint-toggle:hover {
  color: var(--yellow);
}

.hint-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 0 0.5rem;
  border-left: 2px solid var(--border);
  margin-top: 0.5rem;
}

.hint-content.visible {
  max-height: 200px;
}

/* Navigation arrows */
.nav-arrows {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.nav-arrow {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.2s;
}

.nav-arrow:hover {
  color: var(--green);
}

/* Separator */
.separator {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 1.5rem 0;
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-center { text-align: center; }
.text-green { color: var(--green); }
.text-blue { color: var(--blue); }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }
.font-bold { font-weight: 700; }
