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

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

.calculator {
  width: 100%;
  max-width: 375px;
  background: #1c1c1e;
  padding: 16px;
}

/* ディスプレイ */
.display {
  background: #1c1c1e;
  padding: 12px 8px 16px;
  text-align: right;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.display-expression {
  font-size: 18px;
  color: #888;
  min-height: 24px;
  word-break: break-all;
  margin-bottom: 4px;
}

.display-value {
  font-size: 56px;
  color: #fff;
  font-weight: 300;
  word-break: break-all;
  line-height: 1.1;
}

/* ボタングリッド */
.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.btn {
  background: #505050;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 100%;
  aspect-ratio: 1 / 1;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active {
  opacity: 0.7;
}

.btn-gray {
  background: #a5a5a5;
  color: #000;
}

.btn-orange {
  background: #f5a623;
  color: #fff;
}

.btn-orange.active {
  background: #fff;
  color: #f5a623;
}

/* 0ボタン：2列分 */
.btn-wide {
  grid-column: span 2;
  border-radius: 36px;
  justify-content: flex-start;
  padding-left: 28px;
  aspect-ratio: unset;
  height: 72px;
}

@media (max-width: 400px) {
  .display-value {
    font-size: 44px;
  }
  .btn {
    font-size: 20px;
  }
  .btn-wide {
    height: 60px;
    padding-left: 22px;
  }
}
