body {
    font-family: Georgia, 'Times New Roman', Times, serif;
    margin: 20px;
    background-color: #f5f5f5;
}
h1{
    font-size:20px;
}

.controls {
    margin-bottom: 20px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.controls label {
    font-weight: bold;
    margin-right: 10px;
}

.controls input {
    padding: 5px;
    margin-right: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.controls button {
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
}

.controls button:hover {
    background-color: #0056b3;
}

.worksheet {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 15px;
    max-width: 1200px;
    margin: 0 auto;
}

.worksheet:last-child {
    page-break-after: auto;
}

.page-container {
    page-break-after: always;
}

.page-container:last-child {
    page-break-after: auto;
}

.page-header {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
}

.print-title {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 10px;
    display: none;
}

.print-page-info {
    text-align: center;
    font-size: 16px;
    margin-bottom: 20px;
    display: none;
}

.problem {
    text-align: left;
    font-size: 16px;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 4px;
    background-color: #fafafa;
}

.problem .number {
    line-height: 1.2;
    margin: 2px 0;
}

.problem .top-number {
    text-align: right;
    margin-right: 10px;
}

.problem .bottom-row {
    display: flex;
    align-items: center;
    margin: 2px 0;
}

.problem .multiplication-sign {
    font-size: 18px;
    margin-right: 5px;
}

.problem .bottom-number {
    flex: 1;
    text-align: right;
    margin-right: 10px;
}

.problem .line {
    border-bottom: 2px solid #333;
    margin: 5px 0;
    height: 1px;
}

.problem .answer-space {
    height: 25px;
    margin-top: 5px;
}

@media print {
    body {
        margin: 0;
        background-color: white;
    }
    
    .controls {
        display: none;
    }
    
    .worksheet {
        box-shadow: none;
        border-radius: 0;
        padding: 15px;
        max-width: none;
        gap: 8px;
        grid-template-columns: repeat(8, 1fr);
        margin: 0;
    }
    
    .page-container {
        page-break-after: always;
    }
    
    .page-container:last-child {
        page-break-after: auto;
    }
    
    .page-header {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .print-title {
        display: block;
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    .print-page-info {
        display: block;
        font-size: 14px;
        margin-bottom: 15px;
    }
    
    .problem {
        border: 1px solid #ccc;
        background-color: white;
        padding: 8px;
        font-size: 14px;
        page-break-inside: avoid;
    }
}

@page {
    margin: 0.5in;
    size: letter;
}