:root {
  --primary-color: #6366f1;
  --primary-light: #818cf8;
  --text-color: #1e293b;
  --bg-color: #f8fafc;
  --border-color: #e2e8f0;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  min-height: 100vh;
  background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 900px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.back-btn, .help-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-color);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.5);
}

.back-btn:hover, .help-btn:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: translateY(-2px);
}

h1 {
  color: var(--text-color);
  font-size: 1.75rem;
}

.calculator {
  animation: fadeIn 0.5s ease-out;
}

.display {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.expression {
  font-size: 1rem;
  color: var(--text-light);
  min-height: 1.5rem;
  margin-bottom: 0.5rem;
}

#display {
  width: 100%;
  font-size: 2rem;
  text-align: right;
  border: none;
  background: none;
  color: var(--text-color);
  font-weight: 600;
}

.mode-switch {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.mode-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  background: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.scientific-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.basic-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

button {
  padding: 1rem;
  border: none;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  color: var(--text-color);
  box-shadow: var(--shadow);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.operator {
  background: var(--primary-color);
  color: white;
}

.function {
  background: var(--bg-color);
  font-size: 1rem;
}

.equal {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
}

.clear {
  background: #ef4444;
}

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .buttons {
    grid-template-columns: 1fr;
  }

  button {
    padding: 0.875rem;
    font-size: 1rem;
  }

  #display {
    font-size: 1.75rem;
  }

  .scientific-buttons {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 480px) {
  .scientific-buttons {
    grid-template-columns: repeat(3, 1fr);
  }

  button {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .back-btn span {
    display: none;
  }
}
