:root {
  --button-height: 60px;
  --button-font-size: 24px;
}

body {
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 10px;
  background-color: #f4f4f4;
  touch-action: manipulation;
}

.calculator {
  width: 100%;
  max-width: 350px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.display {
  padding: 15px 20px;
  background-color: #222;
  text-align: right;
}

.display input {
  width: 100%;
  padding: 15px 10px;
  font-size: 32px;
  border: none;
  background-color: #444;
  color: white;
  border-radius: 5px;
  box-sizing: border-box;
}

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

.buttons button {
  border: none;
  padding: 0;
  height: var(--button-height);
  font-size: var(--button-font-size);
  cursor: pointer;
  background-color: #fff;
  transition: background-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.buttons button:hover {
  background-color: #eee;
}

.buttons button:active {
  background-color: #ddd;
}

.buttons .clear {
  background-color: #ff0000;
  color: #fff;
}

.buttons .clear:hover {
  background-color: #c40909;
}

.buttons .equals {
  background-color: #ff9500;
  color: white;
  grid-row: span 2;
  height: auto;
}

.buttons .equals:hover {
  background-color: #e68600;
}

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

@media screen and (max-width: 640px) {
  :root {
    --button-height: 70px;
    --button-font-size: 28px;
  }

  .calculator {
    max-width: 90%;
  }

  .display {
    padding: 20px;
  }

  .display input {
    font-size: 40px;
    padding: 20px 15px;
  }
}
