body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f2f5;
    font-family: sans-serif;
}

.container {
    display: flex;
    gap: 20px;
    padding: 20px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
}

/* 計算機本体の外枠 */
.calculator {
    background-color: #333;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 320px;
}

#display {
    width: 100%;
    height: 60px;
    font-size: 2rem;
    text-align: right;
    margin-bottom: 15px;
    padding: 10px;
    box-sizing: border-box;
    border: none;
    background: #eee;
    border-radius: 4px;
}

/* ボタンを4列に並べる重要な設定 */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

button {
    padding: 15px;
    font-size: 1.2rem;
    border: none;
    border-radius: 8px;
    background-color: #555;
    color: white;
    cursor: pointer;
    transition: 0.2s;
}

button:hover {
    background-color: #777;
}

.span-two {
    grid-column: span 2;
}

/* 演算子ボタンの色 */
button[onclick^="appendOperator"], button[onclick="calculate()"] {
    background-color: #f39c12;
}

/* 履歴表示窓の設定 */
.history-panel {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 280px;
    height: 440px; /* 計算機の高さに合わせる */
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.history-panel h3 {
    margin-top: 0;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 10px;
}

#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
    overflow-y: auto; /* 履歴が増えたらスクロール */
    flex-grow: 1;
}

#history-list li {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.refresh-btn {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    background: #333;
    color: white;
    border-radius: 6px;
    cursor: pointer;
}