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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40px;
}

.container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 800px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2em;
}

.section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #555;
    margin-bottom: 15px;
}

.numbers-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.numbers-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.input-wrapper label {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 4px;
}

input[type="number"] {
    width: 100%;
    min-width: 0;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

.target-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.target-input {
    max-width: 200px;
}

.options-box {
    background: #f0f0f0;
    padding: 25px;
    border-radius: 8px;
}

.options-group {
    margin-bottom: 20px;
}

.options-group:last-child {
    margin-bottom: 0;
}

.option-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95em;
    color: #555;
}

.radio-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95em;
    color: #555;
    margin-top: 12px;
}

.buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

button {
    padding: 14px 32px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.solve-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.solve-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.solve-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.clear-btn {
    background: #e0e0e0;
    color: #555;
}

.clear-btn:hover {
    background: #d0d0d0;
}

.results {
    margin-top: 30px;
    padding: 0;
    background: #f8f9fa;
    border-radius: 8px;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease, padding 0.3s ease;
}

.results.show {
    opacity: 1;
    max-height: 2000px;
    padding: 25px;
}

.operation-step {
    padding: 12px 16px;
    background: white;
    border-left: 4px solid #667eea;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 1.05em;
    color: #333;
    word-wrap: break-word;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.step-label {
    font-weight: 700;
}

.step-arithmetic {
    margin-left: auto;
    padding-left: 20px;
}

.final-result {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border-radius: 8px;
    text-align: center;
}

.final-result.exact-match {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.final-result-value {
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 10px;
    word-wrap: break-word;
}

.result-details {
    font-size: 1em;
    opacity: 0.95;
}

.error-message {
    padding: 16px;
    background: #fee;
    border-left: 4px solid #f44;
    border-radius: 4px;
    color: #c33;
    font-weight: 500;
}

.loading {
    text-align: center;
    padding: 40px;
    font-size: 1.1em;
    color: #667eea;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 600px) {
    .numbers-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .container {
        padding: 20px;
    }

    .buttons {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    .radio-group {
        flex-direction: column;
        gap: 10px;
    }
}
