* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Montserrat", sans-serif;
}
body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  transition: background 0.3s ease;
  overflow: hidden;
}
/* Preloader */
#intro {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  color: #fff;
  font-size: 2rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 1;
  transition: opacity 1s ease;
}
#calculator {
  display: none;
}
/* Fade-in animation for calculator */
#calculator.fade-in {
  display: block;
  animation: fadeInCalc 0.8s forwards;
}
@keyframes fadeInCalc {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
/* Calculator styling */
#calculator {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
  padding: 20px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
#display {
  background: transparent;
  border: none;
  color: white;
  font-size: 2.5rem;
  text-align: right;
  padding: 10px;
  outline: none;
  transition: all 0.2s ease;
}
#keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
button {
  border: none;
  border-radius: 12px;
  padding: 20px;
  font-size: 1.3rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transition: all 0.2s ease, box-shadow 0.2s ease;
}
button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}
button:active {
  transform: scale(0.95);
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}
.operator {
  background: rgba(255, 166, 0, 0.6);
  font-weight: 700;
}
.equal {
  background: #2ecc71;
  grid-row: span 2;
}
.zero {
  grid-column: span 2;
}
#history {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.6);
  min-height: 1.5rem;
  text-align: right;
  cursor: pointer;
}
@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(46, 204, 113, 0);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.5);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(46, 204, 113, 0);
  }
}
#display.animate {
  animation: pulse 0.4s ease;
}
.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
}
#themeBtn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  padding: 10px;
  font-size: 1.2rem;
  cursor: pointer;
  color: white;
  transition: 0.3s;
}
#themeBtn:hover {
  background: rgba(255, 255, 255, 0.3);
}
body.light {
  background: linear-gradient(135deg, #f8f9fa, #dbeafe, #e0f2fe);
}
body.light #display {
  color: #222;
}
body.light #calculator {
  background: rgba(255, 255, 255, 0.6);
}
body.light button {
  color: #222;
}
body.light #history {
  color: #222;
}
body.light footer {
  color: #222;
}
footer {
  margin-top: 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
}
/* Responsiveness for mobile */
@media (max-width: 700px) {
  #calculator {
    width: 95vw;
    padding: 3vh 3vw;
    max-height: 95vh;
  }
  #display {
    font-size: 4vw;
    padding: 0.5vh 1vw;
  }
  button {
    font-size: 2.5vw;
    padding: 1.5vh 0;
  }
  #keys {
    gap: 1.2vw;
  }
  footer {
    font-size: 3vw;
  }
  #themeBtn {
    font-size: 3vw;
    padding: 0.8vh;
  }
}