/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Animated background gradient */
body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(-45deg, #141e30, #243b55, #1d2b64, #f8cdda);
  background-size: 400% 400%;
  animation: gradientFlow 12s ease infinite;
}

/* Wrapper */
.app-wrapper {
  padding: 1.5rem;
}

/* Card */
.calculator-card {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 24px;
  padding: 1.8rem 1.6rem 1.6rem;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
  max-width: 360px;
  width: 100%;
  backdrop-filter: blur(18px);
  transform: translateY(0);
  animation: floatUp 0.8s ease-out;
}

/* Title */
.app-title {
  font-size: 1.4rem;
  color: #e5e7eb;
  text-align: center;
  margin-bottom: 0.9rem;
  letter-spacing: 0.06em;
}

/* Screen block (2 lines now) */
.screen {
  background: #020617;
  border-radius: 18px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  box-shadow:
    inset 0 0 0 1px rgba(30, 64, 175, 0.45),
    0 0 22px rgba(59, 130, 246, 0.4);
}

/* Previous line (small text) */
.screen-previous {
  min-height: 20px;
  font-size: 0.9rem;
  color: #9ca3af;
  text-align: right;
  margin-bottom: 0.15rem;
}

/* Current number (big text) */
.screen-current {
  height: 58px;
  color: #f9fafb;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  font-size: 2.2rem;
  overflow: hidden;
  word-wrap: break-word;
  text-shadow: 0 0 12px rgba(59, 130, 246, 0.9);
}

/* Calculator body */
.calculator {
  border-radius: 18px;
  padding: 1rem;
  background: radial-gradient(circle at top left, #1e293b, #020617);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.1);
}

/* Buttons grid */
.buttons-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

/* Base button */
.btn {
  border: none;
  border-radius: 999px;
  padding: 0.8rem 0.2rem;
  font-size: 1.05rem;
  font-weight: 500;
  color: #e5e7eb;
  background: radial-gradient(circle at top, #111827, #020617);
  box-shadow:
    0 7px 14px rgba(15, 23, 42, 0.9),
    0 0 0 1px rgba(148, 163, 184, 0.25);
  cursor: pointer;
  transition:
    transform 0.13s ease,
    box-shadow 0.13s ease,
    background 0.2s ease,
    filter 0.2s ease;
}

/* Zero button wider */
.btn-zero {
  grid-column: span 2;
}

/* Special buttons */
.btn-func {
  background: radial-gradient(circle at top, #4b5563, #111827);
  color: #e5e7eb;
}

.btn-operator {
  background: radial-gradient(circle at top, #1d4ed8, #1e3a8a);
}

.btn-equal {
  background: radial-gradient(circle at top, #22c55e, #15803d);
  box-shadow:
    0 8px 18px rgba(22, 163, 74, 0.7),
    0 0 0 1px rgba(187, 247, 208, 0.35);
}

/* Hover & active animation */
.btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 10px 22px rgba(15, 23, 42, 0.95),
    0 0 18px rgba(59, 130, 246, 0.6);
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(1px) scale(0.97);
  box-shadow:
    0 4px 10px rgba(15, 23, 42, 0.9),
    0 0 10px rgba(59, 130, 246, 0.4);
}

/* Hint text */
.hint-text {
  margin-top: 0.9rem;
  text-align: center;
  font-size: 0.78rem;
  color: #9ca3af;
  opacity: 0;
  animation: fadeIn 0.8s ease forwards;
  animation-delay: 0.5s;
}

/* Animations */
@keyframes gradientFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

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

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

/* Smaller screens */
@media (max-width: 600px) {
  .calculator-card {
    padding: 1.6rem 1.2rem 1.3rem;
  }

  .screen-current {
    font-size: 1.9rem;
  }

  .btn {
    padding: 0.7rem 0.2rem;
    font-size: 0.95rem;
  }
}
