* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'MyUniqueFont';
    touch-action: manipulation;
}

body {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #1c1c1e;
    color: #fff;
    overflow: hidden;
}

.calculator-container {
    width: 100%;
    height: 100%;
    padding: 2vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    max-width: 1200px;
    max-height: 800px;
    min-width: 300px;
    min-height: 500px;
}

.calculator {
    width: 100%;
    height: 100%;
    background-color: #000;
    border-radius: 3vw;
    padding: 2vw;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative; /* 新增：作为返回首页链接的定位父级 */
}

.back-home {
    position: absolute;
    top: 1vw; /* 调整顶部间距 */
    right: 2vw;
    color: #ff9500;
    text-decoration: none;
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    z-index: 999; /* 提高层级 */
    padding: 0.5vw 1vw;
    background: rgba(0,0,0,0.8); /* 增加背景避免遮挡内容 */
    border-radius: 0.5vw;
    transition: 0.3s ease;
    -moz-user-select: none; /* Firefox */
    -webkit-user-select: none; /* Chrome, Safari, Opera */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* 标准语法 */
}

.back-home:hover {
    color: #c47301;
    transform: scale(1.05);
}

.display {
    font-size: clamp(2.5rem, 7vw, 5rem);
    text-align: right;
    padding: 2vw 1vw;
    height: 25%;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    word-break: break-all;
    overflow: hidden;
    margin-top: 2vw; /* 新增：给显示区域顶部留间距，避免被返回链接遮挡 */
}

.scientific-buttons, .standard-buttons {
    height: 70%;
    display: grid;
    gap: clamp(12px, 2vw, 16px);
}

@media (min-width: 768px) {
    .scientific-buttons {
        display: grid;
        grid-template-columns: repeat(10, 1fr);
        grid-template-rows: repeat(5, 1fr);
    }
    .standard-buttons {
        display: none;
    }
    .btn {
        font-size: clamp(1.2rem, 2vw, 2rem);
        border-radius: 50%;
        aspect-ratio: 1 / 1;
    }
    .btn.zero {
        grid-column: span 1;
        border-radius: 50%;
        aspect-ratio: 1 / 1;
    }
}

@media (max-width: 767px) {
    .scientific-buttons {
        display: none;
    }
    .standard-buttons {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }
    .btn {
        font-size: clamp(1.4rem, 5vw, 2.2rem);
        border-radius: 50%;
        aspect-ratio: 1 / 1;
    }
    .btn.zero {
        grid-column: span 2;
        border-radius: 10vw;
        aspect-ratio: 2 / 1;
    }
    /* 手机端调整返回链接样式 */
    .back-home {
        font-size: clamp(1rem, 3vw, 1.2rem);
        top: 1.5vw;
        right: 2vw;
    }
}

.btn {
    width: 65%;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    -moz-user-select: none; /* Firefox */
    -webkit-user-select: none; /* Chrome, Safari, Opera */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* 标准语法 */
}

.btn.num {
    background-color: #333;
    color: #fff;
    -moz-user-select: none; /* Firefox */
    -webkit-user-select: none; /* Chrome, Safari, Opera */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* 标准语法 */
}
.btn.operator {
    background-color: #666;
    color: #fff;
    -moz-user-select: none; /* Firefox */
    -webkit-user-select: none; /* Chrome, Safari, Opera */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* 标准语法 */
}
.btn.orange {
    background-color: #ff9500;
    color: #fff;
    -moz-user-select: none; /* Firefox */
    -webkit-user-select: none; /* Chrome, Safari, Opera */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* 标准语法 */
}
.btn.ac {
    background-color: #a6a6a6;
    color: #000;
    -moz-user-select: none; /* Firefox */
    -webkit-user-select: none; /* Chrome, Safari, Opera */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* 标准语法 */
}

.btn:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}
.btn:active {
    transform: scale(0.98);
}

.btn.mousemove {
    transform: translate(var(--moveX), var(--moveY)) scale(1.05);
}