@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Playfair+Display:ital,wght@0,400;0,700;1,400&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Playfair Display', serif;
    background: linear-gradient(135deg, #F5F5DC 0%, #DCDCDC 50%, #EDEDED 100%);
    background-image: 
        repeating-linear-gradient(90deg, transparent 0px, transparent 20px, rgba(160, 82, 45, 0.05) 20px, rgba(160, 82, 45, 0.05) 21px),
        repeating-linear-gradient(0deg, transparent 0px, transparent 20px, rgba(160, 82, 45, 0.05) 20px, rgba(160, 82, 45, 0.05) 21px);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    position: relative;
    overflow-x: auto;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(205, 133, 63, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(139, 69, 19, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.calculator {
    background: linear-gradient(160deg, #F4E4BC 0%, #E8D5B7 50%, #D4C4A8 100%);
    max-width: 420px;
    width: 100%;
    padding: 40px 30px;
    border-radius: 25px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.15),
        inset 0 2px 10px rgba(255, 255, 255, 0.8),
        0 0 0 3px rgba(205, 133, 63, 0.6),
        0 0 0 6px rgba(255, 255, 255, 0.4);
    border: 8px solid #D2B48C;
    position: relative;
}

.calculator::before {
    content: 'ABACUS • 1752';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(145deg, #F4E4BC, #D2B48C);
    padding: 8px 20px;
    border-radius: 20px;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #8B4513;
    letter-spacing: 1.5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}

.display {
    background: linear-gradient(145deg, #2F1B14 0%, #1A0F0A 100%);
    color: #F4E4BC;
    font-size: 3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 30px 25px;
    text-align: right;
    border-radius: 18px;
    margin-bottom: 30px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    border: 5px solid #DAA520;
    box-shadow: 
        inset 0 0 25px rgba(0, 0, 0, 0.6),
        0 8px 25px rgba(0, 0, 0, 0.2),
        inset 0 2px 8px rgba(255, 255, 255, 0.1);
    letter-spacing: 3px;
    text-shadow: 
        3px 3px 6px rgba(0, 0, 0, 0.9),
        0 0 15px rgba(218, 165, 32, 0.4);
    position: relative;
    overflow: hidden;
}

.display::after {
    content: '';
    position: absolute;
    top: 0;
    right: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shine 4s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 20px;
    height: 450px;
}

.btn-c { grid-area: 1 / 1 / 2 / 3; }
.btn-backspace { grid-area: 1 / 3 / 2 / 4; }
.btn-divide { grid-area: 1 / 4 / 2 / 5; }
.btn-7 { grid-area: 2 / 1 / 3 / 2; }
.btn-8 { grid-area: 2 / 2 / 3 / 3; }
.btn-9 { grid-area: 2 / 3 / 3 / 4; }
.btn-multiply { grid-area: 2 / 4 / 3 / 5; }
.btn-4 { grid-area: 3 / 1 / 4 / 2; }
.btn-5 { grid-area: 3 / 2 / 4 / 3; }
.btn-6 { grid-area: 3 / 3 / 4 / 4; }
.btn-minus { grid-area: 3 / 4 / 4 / 5; }
.btn-1 { grid-area: 4 / 1 / 5 / 2; }
.btn-2 { grid-area: 4 / 2 / 5 / 3; }
.btn-3 { grid-area: 4 / 3 / 5 / 4; }
.btn-plus { grid-area: 4 / 4 / 5 / 5; }
.btn-0 { grid-area: 5 / 1 / 6 / 3; }
.btn-dot { grid-area: 5 / 3 / 6 / 4; }
.btn-equals { grid-area: 5 / 4 / 6 / 6; }

button {
    border: none;
    border-radius: 22px;
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'Playfair Display', serif;
    cursor: pointer;
    position: relative;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 
        0 12px 24px rgba(0, 0, 0, 0.25),
        inset 0 2px 8px rgba(255, 255, 255, 0.3),
        0 4px 12px rgba(139, 69, 19, 0.3);
    text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.7),
        0 0 8px rgba(255, 255, 255, 0.2);
    letter-spacing: 1.5px;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 22px;
    padding: 4px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.2));
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    z-index: -1;
}

button:hover {
    transform: translateY(-6px) scale(1.04);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.35),
        inset 0 2px 12px rgba(255, 255, 255, 0.4),
        0 8px 20px rgba(205, 133, 63, 0.4);
}

button:active {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 
        0 6px 16px rgba(0, 0, 0, 0.3),
        inset 0 4px 12px rgba(0, 0, 0, 0.2);
}

.number {
    background: linear-gradient(145deg, #F5DEB3, #D2B48C);
    color: #5D4037;
    border: 3px solid #DAA520;
}

.number:hover {
    background: linear-gradient(145deg, #FFE4B5, #F0D9B5);
    color: #3E2723;
}

.operator {
    background: linear-gradient(145deg, #A0522D, #8B4513);
    color: #FFF8DC;
    border: 3px solid #CD853F;
}

.operator:hover {
    background: linear-gradient(145deg, #CD853F, #D2691E);
    color: #FAF0E6;
}

.equals {
    background: linear-gradient(145deg, #228B22, #32CD32);
    color: #F0FFF0;
    font-size: 2.1rem;
    border: 4px solid #90EE90;
}

.equals:hover {
    background: linear-gradient(145deg, #32CD32, #7CFC00);
    color: #006400;
}

.clear {
    background: linear-gradient(145deg, #FF8C00, #FF7F50);
    color: #FFF8DC;
    border: 3px solid #FFA07A;
}

.clear:hover {
    background: linear-gradient(145deg, #FF7F50, #FF6347);
    color: #FAF0E6;
}

@media (max-width: 480px) {
    .calculator {
        margin: 20px;
        padding: 30px 25px;
    }
    
    .display {
        font-size: 2.4rem;
        padding: 25px 20px;
    }
    
    .buttons {
        height: 400px;
        gap: 16px;
    }
    
    button {
        font-size: 1.6rem;
    }
}
