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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.calculator-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.calculator-title {
  color: white;
  font-size: 2.5rem;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
  margin-bottom: 10px;
}

.calculator {
  background: white;
  border-radius: 20px;
  padding: 25px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.2);
  display: grid;
  gap: 20px;
  max-width: 900px;
  grid-template-columns: 1fr 300px;
}

/* ディスプレイエリア */
.display {
  grid-column: 1 / -1;
}

.display-input {
  width: 100%;
  height: 80px;
  font-size: 2rem;
  text-align: right;
  border: 2px solid #e1e5e9;
  border-radius: 10px;
  padding: 0 20px;
  background: #f8f9fa;
  color: #333;
  font-weight: bold;
}

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

.btn {
  height: 60px;
  border: none;
  border-radius: 10px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn-number {
  background: linear-gradient(135deg, #74b9ff, #0984e3);
  color: white;
}

.btn-operator {
  background: linear-gradient(135deg, #fd79a8, #e84393);
  color: white;
}

.btn-equals {
  background: linear-gradient(135deg, #00b894, #00a085);
  color: white;
  grid-column: span 2;
}

.btn-clear {
  background: linear-gradient(135deg, #fdcb6e, #e17055);
  color: white;
}

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

/* 履歴エリア */
.history {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 20px;
  height: fit-content;
}

.history h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 1.2rem;
  text-align: center;
}

#history-list {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  background: white;
  padding: 10px 15px;
  margin-bottom: 8px;
  border-radius: 8px;
  font-size: 0.9rem;
  border-left: 4px solid #74b9ff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.history-expression {
  color: #666;
  font-size: 0.8rem;
}

.history-result {
  color: #333;
  font-weight: bold;
  font-size: 1rem;
}

.btn-clear-history {
  width: 100%;
  margin-top: 15px;
  height: 40px;
  font-size: 0.9rem;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
  .calculator {
    grid-template-columns: 1fr;
    max-width: 400px;
    padding: 20px;
  }
  
  .calculator-title {
    font-size: 2rem;
  }
  
  .display-input {
    height: 70px;
    font-size: 1.8rem;
  }
  
  .btn {
    height: 55px;
    font-size: 1.1rem;
  }
  
  .history {
    order: -1;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }
  
  .calculator {
    padding: 15px;
  }
  
  .calculator-title {
    font-size: 1.5rem;
  }
  
  .display-input {
    height: 60px;
    font-size: 1.5rem;
  }
  
  .btn {
    height: 50px;
    font-size: 1rem;
  }
}