:root {
  --bg: #222;
  --key-bg: #444;
  --key-hover: #555;
  --accent-key: #f57c00;
  --font: 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  height: 100vh;
  margin: 0;
  font-family: var(--font);
}

.calculator {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  width: 260px;
}

.calculator-formula {
  background: #111;
  color: #ccc;
  font-size: 0.9rem;
  text-align: right;
  padding: 5px 10px;
  min-height: 20px;
  overflow-x: auto;
}

.calculator-screen {
  width: 100%;
  height: 60px;
  border: none;
  background: #000;
  color: #fff;
  font-size: 2rem;
  text-align: right;
  padding: 0 10px;
}

.calculator-keys {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

button {
  height: 50px;
  font-size: 1.1rem;
  border: 1px solid #333;
  background: var(--key-bg);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--key-hover);
}

.button--operator {
  background: var(--accent-key);
}

.button--operator:hover {
  background: #e65100;
}

.history {
  margin-top: 20px;
  color: #fff;
  font-size: 0.9rem;
  width: 260px;
}

.history h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 10px;
}

#clear-history {
  background: transparent;
  border: none;
  color: #f57c00;
  cursor: pointer;
  font-size: 0.8rem;
}

.history-list {
  list-style: none;
  padding: 0;
  max-height: 150px;
  overflow-y: auto;
}

.history-list li {
  margin-bottom: 5px;
}

@media (max-width: 500px) {
  .calculator {
    width: 100%;
  }
  button {
    font-size: 1rem;
    height: 45px;
  }
  .calculator-screen {
    height: 50px;
    font-size: 1.5rem;
  }
}