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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.calculator {
  width: 340px;
  background: #16213e;
  border-radius: 20px;
  padding: 24px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(108, 92, 231, 0.1);
}

.expression {
  color: #7f8c8d;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 1rem;
  text-align: right;
  padding: 8px 24px 0;
  min-height: 24px;
}

.display {
  background: #0f3460;
  color: #e2e8f0;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 2.4rem;
  text-align: right;
  padding: 20px 24px;
  border-radius: 12px;
  margin-bottom: 20px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  word-break: break-all;
  overflow: hidden;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

.btn {
  padding: 18px;
  font-size: 1.3rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-digit {
  background: #1a1a3e;
  color: #e2e8f0;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-digit:hover {
  background: #2a2a5e;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn-digit:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  background: #12122e;
}

.btn-clear {
  background: #e74c3c;
  color: #fff;
  box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

.btn-clear:hover {
  background: #ff6b5b;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(231, 76, 60, 0.4);
}

.btn-clear:active {
  transform: translateY(0);
  background: #c0392b;
}

.btn-function {
  background: #2d3436;
  color: #dfe6e9;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-function:hover {
  background: #3d4446;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn-function:active {
  transform: translateY(0);
  background: #1e2526;
}

.btn-operator {
  background: #6c5ce7;
  color: #fff;
  box-shadow: 0 4px 8px rgba(108, 92, 231, 0.3);
}

.btn-operator:hover {
  background: #7f6ff0;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(108, 92, 231, 0.4);
}

.btn-operator:active {
  transform: translateY(0);
  background: #5a4bd1;
}

.btn-equals {
  background: #00b894;
  color: #fff;
  box-shadow: 0 4px 8px rgba(0, 184, 148, 0.3);
}

.btn-equals:hover {
  background: #00d4aa;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 184, 148, 0.4);
}

.btn-equals:active {
  transform: translateY(0);
  background: #009b7d;
}

.btn-backspace {
  font-size: 1.1rem;
}

.btn-equals-wide {
  grid-column: span 3;
}

@media (max-width: 400px) {
  .calculator {
    width: 90vw;
    padding: 16px;
  }

  .display {
    font-size: 2rem;
    padding: 16px;
  }

  .btn {
    padding: 14px;
    font-size: 1.1rem;
  }
}
