@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  color-scheme: dark;
  --background: #10131d;
  --panel: #1a2030;
  --display: #121827;
  --key: #252d40;
  --key-hover: #313b52;
  --text: #f5f7ff;
  --muted: #8d98b0;
  --accent: #8b7cff;
  --accent-light: #a99eff;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, #28234d 0, transparent 34%),
    radial-gradient(circle at 85% 85%, #1b3850 0, transparent 32%),
    var(--background);
}

.calculator {
  width: min(100%, 370px);
  padding: 22px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(32,39,58,.98), rgba(22,28,43,.98));
  box-shadow: 0 28px 80px rgba(0,0,0,.45), inset 0 1px rgba(255,255,255,.06);
}

.calculator-header, .calculator-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calculator-header { padding: 2px 3px 20px; }

.brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--accent-light);
}

.mode {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
}

.display {
  min-height: 142px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 12px;
  padding: 22px 18px;
  margin-bottom: 20px;
  overflow: hidden;
  border-radius: 20px;
  background: var(--display);
  box-shadow: inset 0 3px 12px rgba(0,0,0,.22);
}

.history {
  min-height: 20px;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: .04em;
}

.result {
  max-width: 100%;
  overflow: hidden;
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(42px, 12vw, 54px);
  font-weight: 600;
  letter-spacing: -.05em;
  line-height: 1;
}

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

.key {
  min-width: 0;
  height: 66px;
  border: 1px solid rgba(255,255,255,.035);
  border-radius: 18px;
  color: var(--text);
  background: var(--key);
  font: 600 21px 'DM Sans', sans-serif;
  cursor: default;
  box-shadow: 0 5px 12px rgba(0,0,0,.12);
  transition: background .15s ease, transform .15s ease;
}

.key:hover {
  background: var(--key-hover);
  transform: translateY(-1px);
}

.key.utility {
  color: #c4cbe0;
  background: #30384c;
  font-size: 17px;
}

.key.operator {
  color: var(--accent-light);
  background: #302d50;
  font-size: 25px;
}

.key.equals {
  color: white;
  background: linear-gradient(145deg, #9b8cff, #7564e9);
  box-shadow: 0 7px 18px rgba(125,105,239,.28);
}

.key.zero { grid-column: span 2; }

.calculator-footer {
  justify-content: center;
  padding: 19px 0 1px;
  color: #737f99;
  font-size: 11px;
  letter-spacing: .08em;
}

@media (max-width: 400px) {
  .calculator { padding: 17px; border-radius: 25px; }
  .keypad { gap: 8px; }
  .key { height: 60px; border-radius: 15px; }
}
