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

:root {
    --cream: #FAF6F1;
    --magenta: #E91E8C;
    --black: #1A1A1A;
    --gray: #6B6B6B;
    --light-gray: #E5E5E5;
    --dark-magenta: #C71E7A;
}

body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.container {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 32px 0px;
    flex-grow: 1;
}

/* Flores decorativas de fondo */
.bg-flower {
    position: fixed;
    opacity: 0.1;
    pointer-events: none;
    animation: float 8s ease-in-out infinite;
    font-size: 100px;
}

.bg-flower:nth-child(1) {
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.bg-flower:nth-child(2) {
    top: 70%;
    right: 15%;
    animation-delay: 2s;
}

.bg-flower:nth-child(3) {
    bottom: 20%;
    left: 20%;
    animation-delay: 4s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-30px) rotate(10deg);
    }
}

/* Contenedor principal */
.calculator-container {
    max-width: 400px;
    width: 100%;
}

/* Header */
.header {
    text-align: center;
    padding: 16px 32px;
}

.logo {
    font-size: 3rem;
}

.title {
    font-size: 32px;
    color: white;
    font-weight: 300;
    letter-spacing: 3px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Calculadora */
.calculator {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 30px;
    padding: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
}

/* Display */
.display {
    background: linear-gradient(135deg, var(--cream) 0%, #FFE5F1 100%);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.previous-operand {
    color: var(--gray);
    font-size: 1.2rem;
    text-align: right;
    min-height: 1.5rem;
    word-wrap: break-word;
    word-break: break-all;
}

.current-operand {
    color: var(--black);
    font-size: 2.5rem;
    font-weight: 300;
    text-align: right;
    min-height: 3rem;
    word-wrap: break-word;
    word-break: break-all;
}

/* Botones */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
}

.btn {
    padding: 1.5rem;
    border: none;
    border-radius: 15px;
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(-1px);
}

/* Botones numéricos */
.btn-number {
    background: white;
    color: var(--black);
}

.btn-number:hover {
    background: var(--cream);
}

/* Botones de operación */
.btn-operator {
    background: var(--light-gray);
    color: var(--black);
}

.btn-operator:hover {
    background: var(--gray);
    color: white;
}

/* Botón de igual */
.btn-equals {
    background: linear-gradient(135deg, var(--magenta), #ff4db8);
    color: white;
    grid-column: span 4;
}

.btn-equals:hover {
    background: linear-gradient(135deg, var(--dark-magenta), var(--magenta));
    box-shadow: 0 6px 25px rgba(233, 30, 140, 0.4);
}

/* Botón clear */
.btn-clear {
    background: linear-gradient(135deg, #FF6B6B, #EE5A6F);
    color: white;
    grid-column: span 2;
}

.btn-clear:hover {
    background: linear-gradient(135deg, #EE5A6F, #C73866);
}

/* Botón delete */
.btn-delete {
    background: linear-gradient(135deg, #FFA07A, #FF7F50);
    color: white;
}

.btn-delete:hover {
    background: linear-gradient(135deg, #FF7F50, #FF6347);
}

/* Botón de cero especial */
.btn-zero {
    grid-column: span 1;
}

.btn-zero-zero {
    grid-column: span 2;
}

.btn-punto {
    grid-column: span 1;
}

/* Historia */
.history {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(250, 246, 241, 0.5);
    border-radius: 15px;
    max-height: 150px;
    overflow-y: auto;
}

.history-title {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.history-item {
    padding: 0.5rem;
    margin-bottom: 0.3rem;
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--black);
    display: flex;
    justify-content: space-between;
    animation: slideInHistory 0.3s ease;
}

@keyframes slideInHistory {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.history-calculation {
    color: var(--gray);
}

.history-result {
    color: var(--magenta);
    font-weight: 600;
}

.history::-webkit-scrollbar {
    width: 5px;
}

.history::-webkit-scrollbar-track {
    background: transparent;
}

.history::-webkit-scrollbar-thumb {
    background: var(--magenta);
    border-radius: 10px;
}

.clear-history {
    margin-top: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    background: transparent;
    border: 2px solid var(--light-gray);
    border-radius: 10px;
    color: var(--gray);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.clear-history:hover {
    border-color: var(--magenta);
    color: var(--magenta);
}

.footer {
    text-align: center;
    padding: 32px;
}

.enlace {
    color: var(--magenta);
    text-decoration: none;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .calculator {
        padding: 1.5rem;
    }

    .btn {
        padding: 1.2rem;
        font-size: 1.1rem;
    }

    .current-operand {
        font-size: 2rem;
    }

    .title {
        font-size: 1.5rem;
    }
}

@media (max-width: 400px) {
    .btn {
        padding: 1rem;
        font-size: 1rem;
    }

    .buttons {
        gap: 0.5rem;
    }
}