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

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

.calculator {
  background: #16213e;
  border-radius: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  width: 320px;
}

/* Display */
.display {
  padding: 24px 24px 12px;
  text-align: right;
  background: #0f3460;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.expression {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.45);
  min-height: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.result {
  font-size: 52px;
  font-weight: 300;
  color: #e2e2e2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.1;
}

.result.error {
  font-size: 36px;
  color: #ff6b6b;
}

/* Buttons grid */
.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: #0a0a1a;
  padding: 1px;
}

.btn {
  background: #1a2a4a;
  border: none;
  color: #e2e2e2;
  font-size: 22px;
  font-weight: 400;
  padding: 0;
  height: 72px;
  cursor: pointer;
  transition: background 0.1s, transform 0.08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: #233566;
}

.btn:active {
  background: #2a4080;
  transform: scale(0.95);
}

.btn-wide {
  grid-column: span 2;
  text-align: left;
  padding-left: 28px;
}

.btn-op {
  background: #1e3a5f;
  color: #a8c8e8;
}

.btn-op:hover {
  background: #2a4f7f;
}

.btn-highlight {
  background: #e95c2e;
  color: #fff;
  font-weight: 500;
}

.btn-highlight:hover {
  background: #f07040;
}

.btn-highlight:active {
  background: #d04818;
}

.btn-clear {
  color: #ff8080;
}

.btn.active-op {
  background: #fff;
  color: #e95c2e;
}

/* 標示運算來源 */
.footnote {
  padding: 10px 16px 14px;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
  background: #16213e;
}
