
.calculator-header {
    background-color: #2196F3;
    color: white;
    padding: 15px 20px;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0;
    position: relative;
}

.calculator-header span:nth-child(2) {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
.back-to-home {
    font-size: 16px;
    cursor: pointer;
    text-decoration: underline;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 平板设备 */
@media (max-width: 1024px) {
    .calculator-container {
        width: 100%;
        height: 100vh;
        margin: 0;
        padding: 0;
    }
    .calculator-header {
        padding: 12px 16px;
        font-size: 22px;
    }
    .back-to-home {
        font-size: 14px;
    }
    .calculator-body {
        padding: 18px;
    }
    .buttons {
        gap: 12px;
    }
    .buttons button {
        height: 65px;
        font-size: 26px;
    }
    .display {
        min-height: 70px;
        font-size: 26px;
        padding: 14px 18px;
    }
    .result-display {
        height: 80px;
        font-size: 42px;
        padding: 18px 22px;
    }
    .calculator-footer {
        padding: 14px 18px;
        font-size: 16px;
    }
}

/* 小型平板和大屏手机 */
@media (max-width: 768px) {
    .calculator-container {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        padding: 0;
        border-radius: 0;
    }
    .calculator-header {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        font-size: 20px;
        min-height: auto;
    }
    .back-to-home {
        font-size: 14px;
    }
    .buttons {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    .calculator-body {
        padding: 16px;
        flex: 1;
        overflow-y: auto;
    }
    .buttons button {
        height: 60px;
        font-size: 22px;
    }
    .display {
        min-height: 65px;
        font-size: 24px;
        padding: 12px 16px;
    }
    .result-display {
        height: 70px;
        font-size: 36px;
        padding: 15px 20px;
    }
    .calculator-footer {
        padding: 12px 16px;
        font-size: 14px;
    }
    .history.show {
        max-height: 180px;
        margin-top: 20px;
        padding: 12px;
    }
}

/* 中型手机 */
@media (max-width: 640px) {
    .calculator-header {
        gap: 6px;
        padding: 10px;
        font-size: 18px;
    }
    .back-to-home {
        font-size: 13px;
    }
    .calculator-body {
        padding: 14px;
    }
    .buttons {
        gap: 8px;
    }
    .buttons button {
        height: 55px;
        font-size: 20px;
    }
    .display {
        min-height: 60px;
        font-size: 22px;
        padding: 10px 14px;
    }
    .result-display {
        height: 65px;
        font-size: 32px;
        padding: 12px 16px;
    }
    .calculator-footer {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* 小型手机 */
@media (max-width: 480px) {
    .calculator-header {
        gap: 4px;
        padding: 8px;
        font-size: 16px;
    }
    .back-to-home {
        font-size: 12px;
    }
    .calculator-body {
        padding: 12px;
    }
    .buttons {
        gap: 6px;
    }
    .buttons button {
        height: 50px;
        font-size: 18px;
    }
    .display {
        min-height: 55px;
        font-size: 20px;
        padding: 8px 12px;
    }
    .result-display {
        height: 60px;
        font-size: 28px;
        padding: 10px 14px;
    }
    .calculator-footer {
        padding: 8px 12px;
        font-size: 12px;
    }
    .history.show {
        max-height: 150px;
        margin-top: 15px;
        padding: 10px;
    }
    .history-expression {
        font-size: 12px;
    }
    .history-result {
        font-size: 14px;
    }
}

/* 超小屏幕手机 */
@media (max-width: 360px) {
    .calculator-header {
        gap: 3px;
        padding: 6px;
        font-size: 14px;
    }
    .back-to-home {
        font-size: 11px;
    }
    .calculator-body {
        padding: 10px;
    }
    .buttons {
        gap: 5px;
    }
    .buttons button {
        height: 45px;
        font-size: 16px;
    }
    .display {
        min-height: 50px;
        font-size: 18px;
        padding: 8px 10px;
    }
    .result-display {
        height: 55px;
        font-size: 24px;
        padding: 8px 12px;
    }
    .calculator-footer {
        padding: 6px 10px;
        font-size: 11px;
    }
}
.calculator-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.calculator-footer {
    background-color: #f5f5f5;
    color: #666;
    padding: 15px 20px;
    text-align: center;
    font-size: 14px;
    margin-top: auto;
    border-radius: 0;
}
.share-button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    border-radius: 8px;
}
.share-button:hover {
    background-color: #45a049;
    transform: translateY(-2px);
}
.qrcode-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.qrcode-content {
    background-color: white;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-radius: 15px;
}
.qrcode-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
}
.calculator-container {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    background-color: #ffffff;
    overflow: hidden;
}
.display {
    width: 100%;
    min-height: 60px;
    max-height: 120px;
    margin-bottom: 24px;
    padding: 12px 16px;
    background-color: #fff;
    font-size: 24px;
    text-align: left;
    overflow-y: auto;
    border: 2px solid #ddd;
    border-radius: 8px;
    order: -1;
}

.display textarea::placeholder {
    color: #999;
    font-style: normal;
}

.display textarea {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: inherit;
    text-align: left;
    background-color: transparent;
}
.result-display {
    width: 100%;
    height: 70px;
    margin-bottom: 16px;
    padding: 15px 20px;
    background-color: #F5F9FF;
    font-size: 36px;
    font-weight: bold;
    text-align: left;
    color: #1976D2;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border: 3px solid #2196F3;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.15);
}
.buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}
button {
    height: 65px;
    border: none;
    background-color: #f0f0f0;
    font-size: 30px;
    cursor: pointer;
    transition: all 0.1s;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}
button:hover {
    background-color: #e0e0e0;
    transform: translateY(-1px);
}
button:active {
    transform: translateY(0);
    background-color: #d0d0d0;
}

/* 碎花特效样式 */
.petal {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #FFD700;
    border-radius: 50% 0 50% 0;
    pointer-events: none;
    z-index: 1000;
    animation: petal-fall 1s ease-out forwards;
}

.petal:nth-child(2n) {
    background-color: #FF6B6B;
    width: 6px;
    height: 6px;
}

.petal:nth-child(3n) {
    background-color: #4ECDC4;
    width: 10px;
    height: 10px;
}

.petal:nth-child(4n) {
    background-color: #45B7D1;
    width: 7px;
    height: 7px;
}

@keyframes petal-fall {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translate(var(--x, 0), var(--y, -20px)) rotate(var(--rotate, 90deg)) scale(0.8);
    }
    100% {
        opacity: 0;
        transform: translate(var(--x, 0), var(--y, -50px)) rotate(var(--rotate, 180deg)) scale(0.5);
    }
}
.operator {
    background-color: #e3f2fd;
    color: #2196F3;
}
.equals {
    background-color: #4CAF50;
    color: white;
}
.equals:hover {
    background-color: #45a049;
    transform: translateY(-2px);
}
.clear {
    background-color: #ff9800;
    color: white;
}
.clear:hover {
    background-color: #e68900;
    transform: translateY(-2px);
}
.history {
    width: 100%;
    max-height: 0;
    overflow-y: auto;
    margin-top: 0;
    padding: 0;
    background-color: #fafafa;
    transition: all 0.3s ease;
}
.history.show {
    max-height: 200px;
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
}
.history-item {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.history-item:hover {
    background-color: #f5f5f5;
}

.history-item:last-child {
    border-bottom: none;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0e0e0;
}

.history-header h3 {
    font-weight: bold;
    margin: 0;
    color: #333;
    font-size: 16px;
}

.clear-history-btn {
    font-size: 14px;
    color: #2196F3;
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    height: auto;
    transition: color 0.3s;
}

.clear-history-btn:hover {
    color: #1976D2;
    background: none;
    transform: none;
}

.history-expression {
    font-size: 14px;
    color: #666;
    margin-bottom: 4px;
    word-break: break-all;
}

.history-result {
    font-size: 16px;
    font-weight: bold;
    color: #2196F3;
    word-break: break-all;
}

.history-result:hover {
    color: #1976D2;
    text-decoration: underline;
}

/* 基础样式重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #f1f1f1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}

.home-icon {
    margin-right: 4px;
}


.history-expression {
    font-size: 14px;
    color: #666;
}
.history-result {
    font-size: 16px;
    font-weight: bold;
}