/* 重置样式 & 基础设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none; /* 避免按钮文字被选中，更像原生App */
}

body {
    background-color: #000000; /* 纯黑背景，突出计算器 */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: -apple-system, 'Helvetica Neue', Helvetica, 'SF Pro Text', sans-serif;
    font-weight: 400;
    padding: 20px;
}

/* 计算器主体容器 */
.calculator {
    width: 100%;
    max-width: 400px;  /* 限制最大宽度，手机风格 */
    background-color: #000000;
    border-radius: 50px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 15px 30px 15px;
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.5);
}

/* 显示屏区域 */
.display {
    background-color: #000000;
    padding: 20px 20px 10px 20px;
    text-align: right;
    min-height: 140px;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

.display-value {
    color: #ffffff;
    font-size: 70px;
    font-weight: 300;
    letter-spacing: 2px;
    word-wrap: break-word;
    word-break: break-all;
    overflow-wrap: break-word;
    line-height: 1.1;
    transition: all 0.1s ease;
    font-family: inherit;
}

/* 按钮网格布局 */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    background-color: #000000;
}

/* 通用按钮样式 */
.btn {
    aspect-ratio: 1 / 1; /* 保持正方形 */
    border: none;
    border-radius: 60px;
    font-size: 32px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: filter 0.1s ease, transform 0.05s linear;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #333333;
    color: white;
    box-shadow: none;
    outline: none;
}

/* 按钮按下时的视觉反馈 (模拟触感) */
.btn:active {
    filter: brightness(0.85);
    transform: scale(0.97);
}

/* 数字按钮 (深灰色) */
.btn-number {
    background-color: #2a2a2a;
    color: #ffffff;
}

/* 功能按钮 (浅灰色) */
.btn-function {
    background-color: #a5a5a5;
    color: #000000;
    font-weight: 500;
}

/* 运算符按钮 (橙色) */
.btn-operator {
    background-color: #f39c12;
    color: #ffffff;
    font-size: 38px;
    font-weight: 500;
}

/* 等号按钮 (橙色，和运算符一致) */
.btn-equals {
    background-color: #f39c12;
    color: #ffffff;
    font-size: 34px;
}

/* 特殊处理0按钮，使其占满两格？ 但iOS原生计算器0占两格宽度，这里采用grid布局需要单独处理 */
/* 让零按钮占据两列宽度，同时保持高度与其他按钮一致 */
.zero-btn {
    grid-column: span 2;
    aspect-ratio: 2 / 1; /* 宽高比2:1，因为占两格宽度 */
    justify-content: flex-start;
    padding-left: 28px;
}

/* 小数点和正负号按钮正常显示 */
.btn[data-number="."] {
    font-size: 40px;
    font-weight: 600;
}

/* 调整运算符+号字体稍微小一点 */
.btn-operator[data-operator="add"] {
    font-size: 38px;
}

/* 等号字体微调 */
.btn-equals {
    font-size: 34px;
}

/* 响应式：对于较小屏幕，调整字体和内边距 */
@media (max-width: 450px) {
    .calculator {
        max-width: 100%;
        padding: 15px 12px 25px 12px;
        gap: 15px;
    }
    .display-value {
        font-size: 56px;
    }
    .btn {
        font-size: 28px;
    }
    .zero-btn {
        padding-left: 20px;
    }
    .btn-operator {
        font-size: 32px;
    }
}

/* 让按钮更平滑 */
@media (hover: hover) {
    .btn:hover {
        filter: brightness(0.9);
    }
}