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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #07030d;
  font-family: "Syne", sans-serif;
  overflow: hidden;
  color: #f4ecff;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(168, 85, 247, 0.15), transparent 35%),
    radial-gradient(circle at bottom right, rgba(139, 92, 246, 0.12), transparent 40%);
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.12) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  filter: blur(20px);
  pointer-events: none;
}

.wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: #8f7aa8;
}

.calculator {
  width: 320px;
  padding: 20px;
  border-radius: 22px;
  background: #12081d;
  border: 1px solid rgba(168, 85, 247, 0.14);
  box-shadow:
    0 30px 80px rgba(0,0,0,.7),
    0 0 40px rgba(168, 85, 247, .08);
}

.display {
  background: #09040f;
  border: 1px solid rgba(168, 85, 247, .12);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.display-expr {
  font-family: "DM Mono", monospace;
  font-size: 13px;
  color: #84709d;
  word-break: break-all;
}

.display-main {
  font-family: "DM Mono", monospace;
  font-size: 42px;
  font-weight: 300;
  color: #ffffff;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.display-main.small {
  font-size: 28px;
}

.display-main.xsmall {
  font-size: 20px;
}

.display-main.result {
  color: #c084fc;
}

.cursor {
  display: inline-block;
  width: 2px;
  height: .85em;
  background: #a855f7;
  margin-left: 2px;
  animation: blink 1s step-end infinite;
}

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

.btn-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.btn {
  height: 62px;
  border: 1px solid rgba(168, 85, 247, .08);
  border-radius: 16px;
  background: #1a1026;
  color: #f5ecff;
  font-family: "Syne", sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform .12s,
    background .2s,
    border-color .2s,
    box-shadow .2s;
}

.btn:hover {
  background: #241334;
  border-color: rgba(168, 85, 247, .28);
  box-shadow: 0 0 18px rgba(168, 85, 247, .16);
}

.btn:active {
  transform: scale(.94);
}

.btn.span2 {
  grid-column: span 2;
}

.btn.clear {
  background: rgba(255, 77, 109, .08);
  color: #ff5d8f;
  border-color: rgba(255, 77, 109, .2);
}

.btn.clear:hover {
  background: rgba(255, 77, 109, .15);
}

.btn.back {
  color: #9b87b4;
}

.btn.back:hover {
  color: #fff;
}

.btn.op {
  background: #20112d;
  color: #c084fc;
  border-color: rgba(192, 132, 252, .16);
  font-size: 20px;
}

.btn.op:hover {
  background: #2b173d;
  border-color: rgba(192, 132, 252, .35);
}

.btn.op.active-op {
  background: rgba(168, 85, 247, .18);
  border-color: rgba(168, 85, 247, .45);
  box-shadow: 0 0 18px rgba(168, 85, 247, .18);
}

.btn.eq {
  background: linear-gradient(135deg, #7e22ce, #a855f7);
  border-color: #a855f7;
  color: #fff;
  font-size: 24px;
}

.btn.eq:hover {
  background: linear-gradient(135deg, #9333ea, #c084fc);
}

.btn.secondary {
  color: #9b87b4;
  font-size: 18px;
}

.btn.secondary:hover {
  color: #fff;
}

.hint {
  text-align: center;
  font-size: 10px;
  letter-spacing: .18em;
  color: #4d3f63;
  font-family: "DM Mono", monospace;
}

@keyframes flash {
  0% {
    box-shadow: 0 0 0 0 rgba(168, 85, 247, .45);
  }

  100% {
    box-shadow: 0 0 0 12px rgba(168, 85, 247, 0);
  }
}

.flash {
  animation: flash .25s ease-out;
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }

  20%, 60% {
    transform: translateX(-6px);
  }

  40%, 80% {
    transform: translateX(6px);
  }
}

.shake {
  animation: shake .3s ease-out;
}

@media (max-width: 380px) {
  .calculator {
    width: 290px;
    padding: 16px;
  }

  .btn {
    height: 54px;
    font-size: 14px;
  }

  .display-main {
    font-size: 36px;
  }
}