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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1a1a2e, #16213e);
  padding: 1rem;
}

.calculator {
  width: 100%;
  max-width: 360px;
  background: #0f0f1a;
  border-radius: 24px;
  padding: 24px;
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.display {
  background: #1a1a2e;
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 20px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 2.5rem;
  font-weight: 300;
  color: #ffffff;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

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

.btn {
  all: unset;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  border-radius: 16px;
  font-size: 1.4rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
}

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

.btn.number {
  background: #2a2a3e;
  color: #e8e8f0;
  box-shadow: 0 4px 0 #1a1a2e;
}

.btn.number:hover {
  background: #353550;
}

.btn.number:active {
  box-shadow: 0 1px 0 #1a1a2e;
  transform: scale(0.94) translateY(3px);
}

.btn.function {
  background: #3a3a4e;
  color: #ff9f43;
  box-shadow: 0 4px 0 #2a2a3e;
}

.btn.function:hover {
  background: #4a4a5e;
}

.btn.function:active {
  box-shadow: 0 1px 0 #2a2a3e;
  transform: scale(0.94) translateY(3px);
}

.btn.operator {
  background: #ff9f43;
  color: #1a1a2e;
  box-shadow: 0 4px 0 #cc7a2e;
  font-size: 1.6rem;
}

.btn.operator:hover {
  background: #ffb56b;
}

.btn.operator:active {
  box-shadow: 0 1px 0 #cc7a2e;
  transform: scale(0.94) translateY(3px);
}

.btn.operator.active {
  background: #ffffff;
  box-shadow: 0 4px 0 #cccccc;
}

.btn.equals {
  background: #00d2ff;
  color: #1a1a2e;
  box-shadow: 0 4px 0 #0099bb;
  font-size: 1.8rem;
}

.btn.equals:hover {
  background: #33ddff;
}

.btn.equals:active {
  box-shadow: 0 1px 0 #0099bb;
  transform: scale(0.94) translateY(3px);
}

.zero {
  grid-column: span 1;
}

footer {
  margin-top: 2rem;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.85rem;
  text-align: center;
}

@media (max-width: 400px) {
  .calculator {
    padding: 16px;
    border-radius: 16px;
  }
  .display {
    padding: 16px 18px;
    font-size: 2rem;
    min-height: 64px;
  }
  .btn {
    height: 56px;
    font-size: 1.2rem;
    border-radius: 12px;
  }
  .buttons {
    gap: 8px;
  }
}
