body {
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(135deg, #ffd6e7, #c1efff);
    touch-action: manipulation;
}

.calculator {
    background-color: #fff9fc;
    padding: 1.5rem;
    border-radius: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1),
                0 5px 15px rgba(255, 182, 193, 0.2);
    width: 100%;
    max-width: 400px;
    margin: 1rem;
    border: 3px solid #ffe6ee;
}

h1 {
    color: #ff6b9c;
    margin: 0 0 1.5rem 0;
    font-size: 1.8rem;
    text-align: center;
    text-shadow: 1px 1px 0 #fff;
}

.display {
    background: linear-gradient(to bottom, #ffffff, #f8f9fa);
    padding: 1.2rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    text-align: right;
    min-height: 80px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
    border: 2px solid #ffe6ee;
}

.expression {
    font-size: 1.3rem;
    color: #7c7c7c;
    margin-bottom: 0.5rem;
    min-height: 1.5rem;
}

.result {
    font-size: 1.8rem;
    color: #ff6b9c;
    font-weight: bold;
    min-height: 1.8rem;
}

.keypad {
    padding: 0.4rem;
}

.main-pad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
}

button {
    aspect-ratio: 1;
    padding: 0;
    font-size: 1.4rem;
    border: none;
    border-radius: 0.8rem;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: bold;
    position: relative;
}

button::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    transition: opacity 0.2s ease;
    opacity: 0;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

button:hover::after {
    opacity: 1;
}

button:active {
    transform: translateY(2px);
}

.num-btn {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    color: #666;
    border: 2px solid #ffe6ee;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05),
                0 2px 4px rgba(255, 182, 193, 0.1);
}

.num-btn:active {
    background: linear-gradient(145deg, #f0f0f0, #ffffff);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.op-btn {
    background: linear-gradient(145deg, #ffebf3, #ffd6e7);
    color: #ff6b9c;
    border: 2px solid #ffc1d9;
    box-shadow: 0 4px 8px rgba(255, 107, 156, 0.1);
    font-size: 1.6rem;
}

.op-btn:active {
    background: linear-gradient(145deg, #ffd6e7, #ffebf3);
    box-shadow: inset 0 2px 4px rgba(255, 107, 156, 0.2);
}

.equal-btn {
    background: linear-gradient(145deg, #ff8eb3, #ff6b9c);
    color: white;
    border: 2px solid #ff6b9c;
    box-shadow: 0 4px 8px rgba(255, 107, 156, 0.2);
}

.equal-btn:active {
    background: linear-gradient(145deg, #ff6b9c, #ff8eb3);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.clear-btn {
    background: linear-gradient(145deg, #ffa7a7, #ff8989);
    color: white;
    border: 2px solid #ff8989;
    box-shadow: 0 4px 8px rgba(255, 137, 137, 0.2);
}

.clear-btn:active {
    background: linear-gradient(145deg, #ff8989, #ffa7a7);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 移动设备优化 */
@media (max-width: 480px) {
    .calculator {
        margin: 0;
        height: 100vh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        border: none;
        border-top: 3px solid #ffe6ee;
    }

    .keypad {
        flex-grow: 1;
        margin-top: auto;
    }

    button {
        font-size: 1.6rem;
    }

    h1 {
        font-size: 2rem;
    }

    .display {
        margin-bottom: 2rem;
    }
}
